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 | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
40 files changed, 5063 insertions, 0 deletions
diff --git a/noncore/tools/calc2/Makefile b/noncore/tools/calc2/Makefile new file mode 100644 index 0000000..1e31a2f --- a/dev/null +++ b/noncore/tools/calc2/Makefile | |||
@@ -0,0 +1,138 @@ | |||
1 | ############################################################################# | ||
2 | # Makefile for building calc | ||
3 | # Generated by tmake at 12:06, 2001/11/26 | ||
4 | # Project: calc | ||
5 | # Template: app | ||
6 | ############################################################################# | ||
7 | |||
8 | ####### Compiler, tools and options | ||
9 | |||
10 | CC =gcc | ||
11 | CXX =g++ | ||
12 | CFLAGS =-pipe -Wall -W -O2 -DNO_DEBUG | ||
13 | CXXFLAGS=-pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG | ||
14 | INCPATH =-I$(QPEDIR)/include -I$(QTDIR)/include | ||
15 | LINK =gcc | ||
16 | LFLAGS = | ||
17 | LIBS =$(SUBLIBS) -L$(QTDIR)/lib -lqpe -Wl,-export-dynamic -lqte | ||
18 | MOC =$(QTDIR)/bin/moc | ||
19 | UIC =$(QTDIR)/bin/uic | ||
20 | |||
21 | TAR =tar -cf | ||
22 | GZIP =gzip -9f | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =calc.h \ | ||
27 | plugininterface.h \ | ||
28 | instruction.h \ | ||
29 | engine.h \ | ||
30 | stdinstructions.h | ||
31 | SOURCES =calc.cpp \ | ||
32 | main.cpp \ | ||
33 | engine.cpp | ||
34 | OBJECTS =calc.o \ | ||
35 | main.o \ | ||
36 | engine.o | ||
37 | INTERFACES = | ||
38 | UICDECLS = | ||
39 | UICIMPLS = | ||
40 | SRCMOC =moc_calc.cpp \ | ||
41 | moc_engine.cpp | ||
42 | OBJMOC =moc_calc.o \ | ||
43 | moc_engine.o | ||
44 | DIST = | ||
45 | TARGET =calc | ||
46 | INTERFACE_DECL_PATH = . | ||
47 | |||
48 | ####### Implicit rules | ||
49 | |||
50 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
51 | |||
52 | .cpp.o: | ||
53 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
54 | |||
55 | .cxx.o: | ||
56 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
57 | |||
58 | .cc.o: | ||
59 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
60 | |||
61 | .C.o: | ||
62 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
63 | |||
64 | .c.o: | ||
65 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
66 | |||
67 | ####### Build rules | ||
68 | |||
69 | |||
70 | all: $(TARGET) | ||
71 | |||
72 | $(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) | ||
73 | $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
74 | |||
75 | moc: $(SRCMOC) | ||
76 | |||
77 | tmake: | ||
78 | tmake calc.pro | ||
79 | |||
80 | dist: | ||
81 | $(TAR) calc.tar calc.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST) | ||
82 | $(GZIP) calc.tar | ||
83 | |||
84 | clean: | ||
85 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET) | ||
86 | -rm -f *~ core | ||
87 | |||
88 | ####### Sub-libraries | ||
89 | |||
90 | |||
91 | ###### Combined headers | ||
92 | |||
93 | |||
94 | ####### Compile | ||
95 | |||
96 | calc.o: calc.cpp \ | ||
97 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qpeapplication.h \ | ||
98 | calc.h \ | ||
99 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qlibrary.h \ | ||
100 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qcom.h \ | ||
101 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/quuid.h \ | ||
102 | engine.h \ | ||
103 | instruction.h \ | ||
104 | plugininterface.h | ||
105 | |||
106 | main.o: main.cpp \ | ||
107 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qpeapplication.h \ | ||
108 | calc.h \ | ||
109 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qlibrary.h \ | ||
110 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qcom.h \ | ||
111 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/quuid.h \ | ||
112 | engine.h \ | ||
113 | instruction.h \ | ||
114 | plugininterface.h | ||
115 | |||
116 | engine.o: engine.cpp \ | ||
117 | engine.h \ | ||
118 | instruction.h | ||
119 | |||
120 | moc_calc.o: moc_calc.cpp \ | ||
121 | calc.h \ | ||
122 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qlibrary.h \ | ||
123 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/qcom.h \ | ||
124 | /home/luke/builds/2.3.2-emb/qpe/include/qpe/quuid.h \ | ||
125 | engine.h \ | ||
126 | instruction.h \ | ||
127 | plugininterface.h | ||
128 | |||
129 | moc_engine.o: moc_engine.cpp \ | ||
130 | engine.h \ | ||
131 | instruction.h | ||
132 | |||
133 | moc_calc.cpp: calc.h | ||
134 | $(MOC) calc.h -o moc_calc.cpp | ||
135 | |||
136 | moc_engine.cpp: engine.h | ||
137 | $(MOC) engine.h -o moc_engine.cpp | ||
138 | |||
diff --git a/noncore/tools/calc2/binary/Makefile b/noncore/tools/calc2/binary/Makefile new file mode 100644 index 0000000..93cc0d5 --- a/dev/null +++ b/noncore/tools/calc2/binary/Makefile | |||
@@ -0,0 +1,146 @@ | |||
1 | ############################################################################# | ||
2 | # Makefile for building libbinary.so.1.0.0 | ||
3 | # Generated by tmake at 12:03, 2001/11/22 | ||
4 | # Project: binary | ||
5 | # Template: lib | ||
6 | ############################################################################# | ||
7 | |||
8 | ####### Compiler, tools and options | ||
9 | |||
10 | CC =gcc | ||
11 | CXX =g++ | ||
12 | CFLAGS =-pipe -Wall -W -O2 -fPIC -DNO_DEBUG | ||
13 | CXXFLAGS=-pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fPIC -DNO_DEBUG | ||
14 | INCPATH =-I$(QPEDIR)/include -I$(QPEDIR)/calc2 -I$(QTDIR)/include | ||
15 | LINK =gcc | ||
16 | LFLAGS =-shared -Wl,-soname,libbinary.so.1 | ||
17 | LIBS =$(SUBLIBS) -L$(QTDIR)/lib -lqte | ||
18 | AR =ar cqs | ||
19 | RANLIB = | ||
20 | MOC =$(QTDIR)/bin/moc | ||
21 | UIC =$(QTDIR)/bin/uic | ||
22 | |||
23 | TAR =tar -cf | ||
24 | GZIP =gzip -9f | ||
25 | |||
26 | ####### Files | ||
27 | |||
28 | HEADERS =binaryimpl.h \ | ||
29 | binaryfactory.h | ||
30 | SOURCES =binaryimpl.cpp \ | ||
31 | binaryfactory.cpp | ||
32 | OBJECTS =binaryimpl.o \ | ||
33 | binaryfactory.o \ | ||
34 | binary.o | ||
35 | INTERFACES =binary.ui | ||
36 | UICDECLS =binary.h | ||
37 | UICIMPLS =binary.cpp | ||
38 | SRCMOC =moc_binaryimpl.cpp \ | ||
39 | moc_binary.cpp | ||
40 | OBJMOC =moc_binaryimpl.o \ | ||
41 | moc_binary.o | ||
42 | DIST = | ||
43 | TARGET =libbinary.so.1.0.0 | ||
44 | TARGETA =$(QPEDIR)/plugins/calculator/libbinary.a | ||
45 | TARGETD =libbinary.so.1.0.0 | ||
46 | TARGET0 =libbinary.so | ||
47 | TARGET1 =libbinary.so.1 | ||
48 | TARGET2 =libbinary.so.1.0 | ||
49 | INTERFACE_DECL_PATH = . | ||
50 | |||
51 | ####### Implicit rules | ||
52 | |||
53 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
54 | |||
55 | .cpp.o: | ||
56 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
57 | |||
58 | .cxx.o: | ||
59 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
60 | |||
61 | .cc.o: | ||
62 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
63 | |||
64 | .C.o: | ||
65 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
66 | |||
67 | .c.o: | ||
68 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
69 | |||
70 | ####### Build rules | ||
71 | |||
72 | |||
73 | all: $(QPEDIR)/plugins/calculator/libbinary.so.1.0.0 | ||
74 | |||
75 | $(QPEDIR)/plugins/calculator/libbinary.so.1.0.0: $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
76 | -rm -f $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) | ||
77 | $(LINK) $(LFLAGS) -o $(TARGETD) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
78 | -ln -s $(TARGET) $(TARGET0) | ||
79 | -ln -s $(TARGET) $(TARGET1) | ||
80 | -ln -s $(TARGET) $(TARGET2) | ||
81 | -rm -f $(QPEDIR)/plugins/calculator/$(TARGET) | ||
82 | -rm -f $(QPEDIR)/plugins/calculator/$(TARGET0) | ||
83 | -rm -f $(QPEDIR)/plugins/calculator/$(TARGET1) | ||
84 | -rm -f $(QPEDIR)/plugins/calculator/$(TARGET2) | ||
85 | -mv $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(QPEDIR)/plugins/calculator/ | ||
86 | |||
87 | staticlib: $(TARGETA) | ||
88 | |||
89 | $(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC) | ||
90 | -rm -f $(TARGETA) | ||
91 | $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC) | ||
92 | |||
93 | moc: $(SRCMOC) | ||
94 | |||
95 | tmake: | ||
96 | tmake binary.pro | ||
97 | |||
98 | dist: | ||
99 | $(TAR) binary.tar binary.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST) | ||
100 | $(GZIP) binary.tar | ||
101 | |||
102 | clean: | ||
103 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET) | ||
104 | -rm -f $(TARGET0) $(TARGET1) $(TARGET2) $(TARGETA) | ||
105 | -rm -f *~ core | ||
106 | |||
107 | ####### Sub-libraries | ||
108 | |||
109 | |||
110 | ###### Combined headers | ||
111 | |||
112 | |||
113 | ####### Compile | ||
114 | |||
115 | binaryimpl.o: binaryimpl.cpp \ | ||
116 | binaryimpl.h \ | ||
117 | binary.h | ||
118 | |||
119 | binaryfactory.o: binaryfactory.cpp \ | ||
120 | binaryfactory.h \ | ||
121 | binaryimpl.h \ | ||
122 | binary.h | ||
123 | |||
124 | binary.h: binary.ui | ||
125 | $(UIC) binary.ui -o $(INTERFACE_DECL_PATH)/binary.h | ||
126 | |||
127 | binary.cpp: binary.ui | ||
128 | $(UIC) binary.ui -i binary.h -o binary.cpp | ||
129 | |||
130 | binary.o: binary.cpp \ | ||
131 | binary.h \ | ||
132 | binary.ui | ||
133 | |||
134 | moc_binaryimpl.o: moc_binaryimpl.cpp \ | ||
135 | binaryimpl.h \ | ||
136 | binary.h | ||
137 | |||
138 | moc_binary.o: moc_binary.cpp \ | ||
139 | binary.h | ||
140 | |||
141 | moc_binaryimpl.cpp: binaryimpl.h | ||
142 | $(MOC) binaryimpl.h -o moc_binaryimpl.cpp | ||
143 | |||
144 | moc_binary.cpp: binary.h | ||
145 | $(MOC) binary.h -o moc_binary.cpp | ||
146 | |||
diff --git a/noncore/tools/calc2/binary/README b/noncore/tools/calc2/binary/README new file mode 100644 index 0000000..4937038 --- a/dev/null +++ b/noncore/tools/calc2/binary/README | |||
@@ -0,0 +1 @@ | |||
A binary interface with bitwise operations | |||
diff --git a/noncore/tools/calc2/binary/binary.pro b/noncore/tools/calc2/binary/binary.pro new file mode 100644 index 0000000..01ba6a4 --- a/dev/null +++ b/noncore/tools/calc2/binary/binary.pro | |||
@@ -0,0 +1,16 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG -= moc | ||
3 | CONFIG += qt release | ||
4 | |||
5 | # Input | ||
6 | INTERFACES += binary.ui | ||
7 | HEADERS = binaryimpl.h \ | ||
8 | binaryfactory.h | ||
9 | SOURCES = binaryimpl.cpp \ | ||
10 | binaryfactory.cpp | ||
11 | |||
12 | INCLUDEPATH += $(QPEDIR)/include \ | ||
13 | $(QPEDIR)/calc2 | ||
14 | DEPENDPATH += $(QPEDIR)/include | ||
15 | |||
16 | DESTDIR = $(QPEDIR)/plugins/calculator | ||
diff --git a/noncore/tools/calc2/binary/binary.ui b/noncore/tools/calc2/binary/binary.ui new file mode 100644 index 0000000..26064d1 --- a/dev/null +++ b/noncore/tools/calc2/binary/binary.ui | |||
@@ -0,0 +1,177 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>FormBinary</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>FormBinary</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>332</width> | ||
15 | <height>114</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Binary</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>0</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>0</number> | ||
30 | </property> | ||
31 | <widget row="1" column="0" > | ||
32 | <class>QPushButton</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>PB0</cstring> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>maximumSize</name> | ||
39 | <size> | ||
40 | <width>80</width> | ||
41 | <height>80</height> | ||
42 | </size> | ||
43 | </property> | ||
44 | <property stdset="1"> | ||
45 | <name>text</name> | ||
46 | <string>0</string> | ||
47 | </property> | ||
48 | </widget> | ||
49 | <widget row="1" column="1" > | ||
50 | <class>QPushButton</class> | ||
51 | <property stdset="1"> | ||
52 | <name>name</name> | ||
53 | <cstring>PB1</cstring> | ||
54 | </property> | ||
55 | <property stdset="1"> | ||
56 | <name>maximumSize</name> | ||
57 | <size> | ||
58 | <width>80</width> | ||
59 | <height>80</height> | ||
60 | </size> | ||
61 | </property> | ||
62 | <property stdset="1"> | ||
63 | <name>text</name> | ||
64 | <string>1</string> | ||
65 | </property> | ||
66 | </widget> | ||
67 | <widget row="0" column="0" > | ||
68 | <class>QPushButton</class> | ||
69 | <property stdset="1"> | ||
70 | <name>name</name> | ||
71 | <cstring>PBAnd</cstring> | ||
72 | </property> | ||
73 | <property stdset="1"> | ||
74 | <name>maximumSize</name> | ||
75 | <size> | ||
76 | <width>80</width> | ||
77 | <height>80</height> | ||
78 | </size> | ||
79 | </property> | ||
80 | <property stdset="1"> | ||
81 | <name>text</name> | ||
82 | <string>AND</string> | ||
83 | </property> | ||
84 | </widget> | ||
85 | <widget row="0" column="1" > | ||
86 | <class>QPushButton</class> | ||
87 | <property stdset="1"> | ||
88 | <name>name</name> | ||
89 | <cstring>PBOr</cstring> | ||
90 | </property> | ||
91 | <property stdset="1"> | ||
92 | <name>maximumSize</name> | ||
93 | <size> | ||
94 | <width>80</width> | ||
95 | <height>80</height> | ||
96 | </size> | ||
97 | </property> | ||
98 | <property stdset="1"> | ||
99 | <name>text</name> | ||
100 | <string>OR</string> | ||
101 | </property> | ||
102 | </widget> | ||
103 | <widget row="0" column="2" > | ||
104 | <class>QPushButton</class> | ||
105 | <property stdset="1"> | ||
106 | <name>name</name> | ||
107 | <cstring>PBNot</cstring> | ||
108 | </property> | ||
109 | <property stdset="1"> | ||
110 | <name>maximumSize</name> | ||
111 | <size> | ||
112 | <width>80</width> | ||
113 | <height>80</height> | ||
114 | </size> | ||
115 | </property> | ||
116 | <property stdset="1"> | ||
117 | <name>text</name> | ||
118 | <string>NOT</string> | ||
119 | </property> | ||
120 | </widget> | ||
121 | <widget row="1" column="2" > | ||
122 | <class>QPushButton</class> | ||
123 | <property stdset="1"> | ||
124 | <name>name</name> | ||
125 | <cstring>PBSHL</cstring> | ||
126 | </property> | ||
127 | <property stdset="1"> | ||
128 | <name>maximumSize</name> | ||
129 | <size> | ||
130 | <width>80</width> | ||
131 | <height>80</height> | ||
132 | </size> | ||
133 | </property> | ||
134 | <property stdset="1"> | ||
135 | <name>text</name> | ||
136 | <string><-</string> | ||
137 | </property> | ||
138 | </widget> | ||
139 | <widget row="0" column="3" > | ||
140 | <class>QPushButton</class> | ||
141 | <property stdset="1"> | ||
142 | <name>name</name> | ||
143 | <cstring>PBXor</cstring> | ||
144 | </property> | ||
145 | <property stdset="1"> | ||
146 | <name>maximumSize</name> | ||
147 | <size> | ||
148 | <width>80</width> | ||
149 | <height>80</height> | ||
150 | </size> | ||
151 | </property> | ||
152 | <property stdset="1"> | ||
153 | <name>text</name> | ||
154 | <string>XOR</string> | ||
155 | </property> | ||
156 | </widget> | ||
157 | <widget row="1" column="3" > | ||
158 | <class>QPushButton</class> | ||
159 | <property stdset="1"> | ||
160 | <name>name</name> | ||
161 | <cstring>PBSHR</cstring> | ||
162 | </property> | ||
163 | <property stdset="1"> | ||
164 | <name>maximumSize</name> | ||
165 | <size> | ||
166 | <width>80</width> | ||
167 | <height>80</height> | ||
168 | </size> | ||
169 | </property> | ||
170 | <property stdset="1"> | ||
171 | <name>text</name> | ||
172 | <string>-></string> | ||
173 | </property> | ||
174 | </widget> | ||
175 | </grid> | ||
176 | </widget> | ||
177 | </UI> | ||
diff --git a/noncore/tools/calc2/binary/binaryfactory.cpp b/noncore/tools/calc2/binary/binaryfactory.cpp new file mode 100644 index 0000000..110334f --- a/dev/null +++ b/noncore/tools/calc2/binary/binaryfactory.cpp | |||
@@ -0,0 +1,51 @@ | |||
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 | ** 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 | **********************************************************************/ | ||
22 | |||
23 | #include "binaryfactory.h" | ||
24 | #include "binaryimpl.h" | ||
25 | #include <engine.h> | ||
26 | |||
27 | QWidget *BinaryInterface::getPlugin ( Engine *e, QWidget *parent ) { | ||
28 | if ( !input ) | ||
29 | input = new FormBinaryImpl ( e, parent ); | ||
30 | return input; | ||
31 | } | ||
32 | |||
33 | #ifndef QT_NO_COMPONENT | ||
34 | QRESULT BinaryInterface::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
35 | { | ||
36 | *iface = 0; | ||
37 | if ( uuid == IID_QUnknown ) | ||
38 | *iface = this; | ||
39 | else if ( uuid == IID_Calc ) | ||
40 | *iface = this; | ||
41 | |||
42 | if ( *iface ) | ||
43 | (*iface)->addRef(); | ||
44 | return QS_OK; | ||
45 | } | ||
46 | |||
47 | Q_EXPORT_INTERFACE() | ||
48 | { | ||
49 | Q_CREATE_INSTANCE( BinaryInterface ) | ||
50 | } | ||
51 | #endif | ||
diff --git a/noncore/tools/calc2/binary/binaryfactory.h b/noncore/tools/calc2/binary/binaryfactory.h new file mode 100644 index 0000000..e015384 --- a/dev/null +++ b/noncore/tools/calc2/binary/binaryfactory.h | |||
@@ -0,0 +1,46 @@ | |||
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 | #ifndef BINARYIMPL_H | ||
22 | #define BINARYIMPL_H | ||
23 | |||
24 | #include "binaryimpl.h" | ||
25 | #include <plugininterface.h> | ||
26 | #include <engine.h> | ||
27 | |||
28 | class BinaryInterface : public CalcInterface | ||
29 | { | ||
30 | public: | ||
31 | BinaryInterface(){input = 0;}; | ||
32 | virtual ~BinaryInterface(){}; | ||
33 | |||
34 | #ifndef QT_NO_COMPONENT | ||
35 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
36 | Q_REFCOUNT | ||
37 | #endif | ||
38 | |||
39 | QWidget *getPlugin( Engine *, QWidget *parent ); | ||
40 | |||
41 | private: | ||
42 | FormBinaryImpl *input; | ||
43 | ulong ref; | ||
44 | }; | ||
45 | |||
46 | #endif | ||
diff --git a/noncore/tools/calc2/binary/binaryimpl.cpp b/noncore/tools/calc2/binary/binaryimpl.cpp new file mode 100644 index 0000000..ffc56ad --- a/dev/null +++ b/noncore/tools/calc2/binary/binaryimpl.cpp | |||
@@ -0,0 +1,110 @@ | |||
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 "binaryimpl.h" | ||
22 | #include <instruction.h> | ||
23 | |||
24 | class iXOR : public Instruction { | ||
25 | public: | ||
26 | iXOR():Instruction(){}; | ||
27 | ~iXOR(){}; | ||
28 | Data eval(Data num) { | ||
29 | Data result; | ||
30 | result.i = num.i ^ acc.i; | ||
31 | return result; | ||
32 | }; | ||
33 | }; | ||
34 | class iAND : public Instruction { | ||
35 | public: | ||
36 | iAND():Instruction(){}; | ||
37 | ~iAND(){}; | ||
38 | Data eval(Data num) { | ||
39 | Data result; | ||
40 | result.i = num.i & acc.i; | ||
41 | return result; | ||
42 | }; | ||
43 | }; | ||
44 | class iNOT : public Instruction { | ||
45 | public: | ||
46 | iNOT():Instruction(){}; | ||
47 | ~iNOT(){}; | ||
48 | Data eval(Data num) { | ||
49 | Data result; | ||
50 | result.i = ~ num.i; | ||
51 | return result; | ||
52 | }; | ||
53 | }; | ||
54 | class iOR : public Instruction { | ||
55 | public: | ||
56 | iOR():Instruction(){}; | ||
57 | ~iOR(){}; | ||
58 | Data eval(Data num) { | ||
59 | Data result; | ||
60 | result.i = num.i | acc.i; | ||
61 | return result; | ||
62 | }; | ||
63 | }; | ||
64 | class iLSH : public Instruction { | ||
65 | public: | ||
66 | iLSH():Instruction(){}; | ||
67 | ~iLSH(){}; | ||
68 | Data eval(Data num) { | ||
69 | Data result; | ||
70 | result.i = num.i << 1; | ||
71 | return result; | ||
72 | }; | ||
73 | }; | ||
74 | class iRSH : public Instruction { | ||
75 | public: | ||
76 | iRSH():Instruction(){}; | ||
77 | ~iRSH(){}; | ||
78 | Data eval(Data num) { | ||
79 | Data result; | ||
80 | result.i = num.i >> 1; | ||
81 | return result; | ||
82 | }; | ||
83 | }; | ||
84 | |||
85 | void FormBinaryImpl::val0Clicked() { | ||
86 | engine->pushValue('0'); | ||
87 | } | ||
88 | |||
89 | void FormBinaryImpl::val1Clicked() { | ||
90 | engine->pushValue('1'); | ||
91 | } | ||
92 | |||
93 | void FormBinaryImpl::XORClicked() { | ||
94 | engine->pushInstruction(new iXOR()); | ||
95 | } | ||
96 | void FormBinaryImpl::ANDClicked() { | ||
97 | engine->pushInstruction(new iAND()); | ||
98 | } | ||
99 | void FormBinaryImpl::NOTClicked() { | ||
100 | engine->immediateInstruction(new iNOT()); | ||
101 | } | ||
102 | void FormBinaryImpl::ORClicked() { | ||
103 | engine->pushInstruction(new iOR()); | ||
104 | } | ||
105 | void FormBinaryImpl::LSHClicked() { | ||
106 | engine->immediateInstruction(new iLSH()); | ||
107 | } | ||
108 | void FormBinaryImpl::RSHClicked() { | ||
109 | engine->immediateInstruction(new iRSH()); | ||
110 | } | ||
diff --git a/noncore/tools/calc2/binary/binaryimpl.h b/noncore/tools/calc2/binary/binaryimpl.h new file mode 100644 index 0000000..bf9e3a7 --- a/dev/null +++ b/noncore/tools/calc2/binary/binaryimpl.h | |||
@@ -0,0 +1,50 @@ | |||
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 FORMBINARYINPUTIMPL | ||
21 | #define FORMBINARYINPUTIMPL | ||
22 | |||
23 | #include "binary.h" | ||
24 | #include <engine.h> | ||
25 | |||
26 | class FormBinaryImpl : public FormBinary { | ||
27 | Q_OBJECT | ||
28 | public: | ||
29 | FormBinaryImpl(Engine *e,QWidget *p) : FormBinary (p,"Binary") { | ||
30 | engine = e; | ||
31 | engine->setRepresentation(rBin); | ||
32 | }; | ||
33 | ~FormBinaryImpl(){}; | ||
34 | private: | ||
35 | Engine *engine; | ||
36 | |||
37 | private slots: | ||
38 | void val0Clicked(); | ||
39 | void val1Clicked(); | ||
40 | |||
41 | void XORClicked(); | ||
42 | void ANDClicked(); | ||
43 | void NOTClicked(); | ||
44 | void ORClicked(); | ||
45 | |||
46 | void LSHClicked(); | ||
47 | void RSHClicked(); | ||
48 | }; | ||
49 | |||
50 | #endif | ||
diff --git a/noncore/tools/calc2/calc.cpp b/noncore/tools/calc2/calc.cpp new file mode 100644 index 0000000..883ab33 --- a/dev/null +++ b/noncore/tools/calc2/calc.cpp | |||
@@ -0,0 +1,104 @@ | |||
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 <qvaluelist.h> | ||
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qdir.h> | ||
24 | #include <qwidgetstack.h> | ||
25 | |||
26 | #include "calc.h" | ||
27 | #include "plugininterface.h" | ||
28 | |||
29 | calc::calc (QWidget * p = 0, const char *n = 0):QWidget (p, n) | ||
30 | { | ||
31 | setCaption (tr ("Calculator")); | ||
32 | |||
33 | // widgets | ||
34 | LCD = new QLCDNumber (this); | ||
35 | LCD->setMaximumSize (QSize (240, 30)); | ||
36 | LCD->setNumDigits(12); | ||
37 | LCD->setSegmentStyle(QLCDNumber::Filled); | ||
38 | pluginWidgetStack = new QWidgetStack (this); | ||
39 | |||
40 | // layout widgets | ||
41 | calculatorLayout = new QVBoxLayout (this); | ||
42 | calculatorLayout->addWidget (LCD); | ||
43 | calculatorLayout->addWidget (pluginWidgetStack); | ||
44 | |||
45 | // no formatting of display for now | ||
46 | connect (&engine, SIGNAL(display (double)), LCD, SLOT(display (double))); | ||
47 | connect (&engine, SIGNAL(display (const QString &)), LCD, SLOT(display (const QString &))); | ||
48 | connect (&engine, SIGNAL(setBinMode()), LCD, SLOT(setBinMode())); | ||
49 | connect (&engine, SIGNAL(setOctMode()), LCD, SLOT(setOctMode())); | ||
50 | connect (&engine, SIGNAL(setDecMode()), LCD, SLOT(setDecMode())); | ||
51 | connect (&engine, SIGNAL(setHexMode()), LCD, SLOT(setHexMode())); | ||
52 | |||
53 | #ifndef NO_PLUGINS | ||
54 | // load plugins | ||
55 | QValueList < Plugin >::Iterator mit; | ||
56 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { | ||
57 | (*mit).interface->release (); | ||
58 | (*mit).library->unload (); | ||
59 | delete (*mit).library; | ||
60 | } | ||
61 | pluginList.clear (); | ||
62 | |||
63 | QString path = QPEApplication::qpeDir() + "/plugins/calculator"; | ||
64 | QDir dir (path, "lib*.so"); | ||
65 | QStringList list = dir.entryList (); | ||
66 | |||
67 | QStringList::Iterator it; | ||
68 | for (it = list.begin (); it != list.end (); ++it) { | ||
69 | CalcInterface *iface = 0; | ||
70 | QLibrary *lib = new QLibrary (path + "/" + *it); | ||
71 | |||
72 | Plugin plugin; | ||
73 | plugin.pluginWidget = 0; | ||
74 | |||
75 | if (lib->queryInterface (IID_Calc, (QUnknownInterface **) & iface) == | ||
76 | QS_OK) { | ||
77 | plugin.library = lib; | ||
78 | plugin.interface = iface; | ||
79 | plugin.pluginWidget = plugin.interface->getPlugin(&engine,pluginWidgetStack); | ||
80 | if (plugin.pluginWidget) | ||
81 | pluginWidgetStack->addWidget (plugin.pluginWidget, pluginList.count()); | ||
82 | pluginList.append (plugin); | ||
83 | } else { | ||
84 | delete lib; | ||
85 | } | ||
86 | } | ||
87 | setMode (1); | ||
88 | #else | ||
89 | // load simple interface | ||
90 | #endif | ||
91 | } | ||
92 | |||
93 | calc::~calc () | ||
94 | { | ||
95 | #ifndef NO_PLUGINS | ||
96 | QValueList < Plugin >::Iterator mit; | ||
97 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { | ||
98 | (*mit).interface->release (); | ||
99 | (*mit).library->unload (); | ||
100 | delete (*mit).library; | ||
101 | } | ||
102 | #endif | ||
103 | } | ||
104 | |||
diff --git a/noncore/tools/calc2/calc.h b/noncore/tools/calc2/calc.h new file mode 100644 index 0000000..b52356d --- a/dev/null +++ b/noncore/tools/calc2/calc.h | |||
@@ -0,0 +1,69 @@ | |||
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 | #ifndef CALC_H | ||
22 | #define CALC_H | ||
23 | |||
24 | #ifdef QT_NO_COMPONENT | ||
25 | #define NO_PLUGINS | ||
26 | #endif | ||
27 | |||
28 | #include <qlayout.h> | ||
29 | #include <qwidgetstack.h> | ||
30 | |||
31 | #ifndef NO_PLUGINS | ||
32 | #include <qvaluelist.h> | ||
33 | #include <qpe/qlibrary.h> | ||
34 | #endif | ||
35 | |||
36 | #include "engine.h" | ||
37 | #include "plugininterface.h" | ||
38 | |||
39 | struct Plugin { | ||
40 | #ifndef NO_PLUGINS | ||
41 | QLibrary *library; | ||
42 | #endif | ||
43 | QWidget *pluginWidget; | ||
44 | CalcInterface *interface; | ||
45 | QString name; | ||
46 | }; | ||
47 | |||
48 | class calc:public QWidget { | ||
49 | |||
50 | Q_OBJECT | ||
51 | public: | ||
52 | calc (QWidget * p = 0, const char *n = 0); | ||
53 | ~calc (); | ||
54 | |||
55 | private: | ||
56 | #ifndef NO_PLUGINS | ||
57 | void loadPlugins (); | ||
58 | QValueList < Plugin > pluginList; | ||
59 | #endif | ||
60 | QVBoxLayout *calculatorLayout; | ||
61 | QWidgetStack *pluginWidgetStack; | ||
62 | QLCDNumber *LCD; | ||
63 | Engine engine; | ||
64 | |||
65 | public slots: | ||
66 | void setMode(int m){pluginWidgetStack->raiseWidget(m);}; | ||
67 | }; | ||
68 | |||
69 | #endif | ||
diff --git a/noncore/tools/calc2/calc.pro b/noncore/tools/calc2/calc.pro new file mode 100644 index 0000000..c10232a --- a/dev/null +++ b/noncore/tools/calc2/calc.pro | |||
@@ -0,0 +1,11 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG += qt release | ||
3 | |||
4 | # Input | ||
5 | HEADERS += calc.h plugininterface.h instruction.h engine.h stdinstructions.h | ||
6 | SOURCES += calc.cpp main.cpp engine.cpp | ||
7 | |||
8 | INCLUDEPATH += $(QPEDIR)/include | ||
9 | DEPENDPATH += $(QPEDIR)/include | ||
10 | LIBS += -lqpe -Wl,-export-dynamic | ||
11 | |||
diff --git a/noncore/tools/calc2/engine.cpp b/noncore/tools/calc2/engine.cpp new file mode 100644 index 0000000..a9a47c4 --- a/dev/null +++ b/noncore/tools/calc2/engine.cpp | |||
@@ -0,0 +1,214 @@ | |||
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 "engine.h" | ||
22 | #include <qstring.h> | ||
23 | #include <math.h> | ||
24 | #include <qlcdnumber.h> | ||
25 | |||
26 | Data Engine::evalStack (Data num, bool inbrace = FALSE) | ||
27 | { | ||
28 | if (state != sError) { | ||
29 | Instruction *i; | ||
30 | |||
31 | // Pop the next op from the stack | ||
32 | while (!stack.isEmpty () && (braces || !inbrace)) { | ||
33 | i = stack.pop (); | ||
34 | |||
35 | // Check this ops prec vs next ops prec | ||
36 | if (!stack.isEmpty ()) | ||
37 | if (i->precedence <= stack.top()->precedence) | ||
38 | i->acc = evalStack (i->acc, inbrace); | ||
39 | |||
40 | // Evaluate this instruction | ||
41 | num = i->eval (num); | ||
42 | |||
43 | // Error-check ( change this to work for all types ) | ||
44 | if (isnan (num.dbl) || isinf (num.dbl)) { | ||
45 | qDebug ("bad result from operation"); | ||
46 | state = sError; | ||
47 | clearData(&num); | ||
48 | return num; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | return num; | ||
53 | } | ||
54 | |||
55 | // Plugins call this to request the stack be evaluated | ||
56 | void Engine::eval () | ||
57 | { | ||
58 | num = evalStack (num); | ||
59 | if (state != sError) { | ||
60 | displayData(num); | ||
61 | state = sStart; | ||
62 | } | ||
63 | // if the user didnt close all their braces, its no big deal | ||
64 | braces = 0; | ||
65 | } | ||
66 | |||
67 | void Engine::immediateInstruction (Instruction * i) | ||
68 | { | ||
69 | if (state != sError) { | ||
70 | i->setRep(currentRep); | ||
71 | num = i->eval (num); | ||
72 | displayData(num); | ||
73 | state = sStart; | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void Engine::pushInstruction (Instruction * i) | ||
78 | { | ||
79 | if (state != sError) { | ||
80 | i->setRep(currentRep); | ||
81 | i->acc = num; | ||
82 | stack.push (i); | ||
83 | state = sStart; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | void Engine::pushValue (char v) | ||
88 | { | ||
89 | if (state == sAppend) { | ||
90 | bool ok = FALSE; | ||
91 | switch (currentRep) { | ||
92 | case rDouble: | ||
93 | displayString.append(v); | ||
94 | num.dbl=displayString.toDouble(&ok); | ||
95 | break; | ||
96 | case rFraction: | ||
97 | break; | ||
98 | default: | ||
99 | displayString.append(v); | ||
100 | num.i=displayString.toInt(&ok, calcBase()); | ||
101 | }; | ||
102 | if (!ok) { | ||
103 | state = sError; | ||
104 | qDebug("pushValue() - num->string conversion"); | ||
105 | } else { | ||
106 | const QString constString = displayString; | ||
107 | emit(display(constString)); | ||
108 | }; | ||
109 | |||
110 | } else if (state == sStart) { | ||
111 | softReset(); | ||
112 | displayString.truncate(0); | ||
113 | state = sAppend; | ||
114 | pushValue (v); | ||
115 | } else if (state == sError) { | ||
116 | qDebug ("in error state"); | ||
117 | return; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void Engine::del () | ||
122 | { | ||
123 | bool ok; | ||
124 | switch (currentRep) { | ||
125 | case rDouble: | ||
126 | displayString.truncate(displayString.length()); | ||
127 | num.dbl=displayString.toDouble(&ok); | ||
128 | break; | ||
129 | case rFraction: | ||
130 | qDebug("not available"); | ||
131 | break; | ||
132 | default: | ||
133 | displayString.truncate(displayString.length()); | ||
134 | num.i = displayString.toInt(&ok, calcBase()); | ||
135 | }; | ||
136 | |||
137 | if (!ok) { | ||
138 | state = sError; | ||
139 | qDebug("del() - num->string conversion"); | ||
140 | } else { | ||
141 | const QString constString = displayString; | ||
142 | emit(display(constString)); | ||
143 | }; | ||
144 | } | ||
145 | |||
146 | void Engine::displayData(Data d) { | ||
147 | switch (currentRep) { | ||
148 | case rDouble: | ||
149 | displayString.setNum(d.dbl); | ||
150 | break; | ||
151 | case rFraction: | ||
152 | qDebug("fractional display not yet impl"); | ||
153 | break; | ||
154 | default: | ||
155 | displayString.setNum(d.i, calcBase()); | ||
156 | break; | ||
157 | }; | ||
158 | const QString constString= displayString; | ||
159 | emit(display(constString)); | ||
160 | } | ||
161 | |||
162 | // Returns the base when Rep is an integer type | ||
163 | int Engine::calcBase () { | ||
164 | switch (currentRep) { | ||
165 | case rBin: | ||
166 | return 2; | ||
167 | case rOct: | ||
168 | return 8; | ||
169 | case rDec: | ||
170 | return 10; | ||
171 | case rHex: | ||
172 | return 16; | ||
173 | default: | ||
174 | state = sError; | ||
175 | qDebug("Error - attempt to calc base for non-integer"); | ||
176 | return 10; | ||
177 | }; | ||
178 | } | ||
179 | |||
180 | // Special instruction for internal use only | ||
181 | class iOpenBrace:public Instruction { | ||
182 | public: | ||
183 | iOpenBrace (Engine *e):Instruction (100) {engine = e;}; | ||
184 | ~iOpenBrace () {}; | ||
185 | |||
186 | Data eval (Data num) { | ||
187 | engine->decBraces(); | ||
188 | return num; | ||
189 | }; | ||
190 | private: | ||
191 | Engine *engine; | ||
192 | }; | ||
193 | |||
194 | void Engine::openBrace() { | ||
195 | pushInstruction(new iOpenBrace(this)); | ||
196 | } | ||
197 | |||
198 | void Engine::closeBrace() { | ||
199 | braces++;evalStack(num,TRUE); | ||
200 | } | ||
201 | |||
202 | // will need to show and hide display widgets | ||
203 | void Engine::setRepresentation(Representation r) { | ||
204 | currentRep = r; | ||
205 | clearData(&num); | ||
206 | clearData(&mem); | ||
207 | state = sStart; | ||
208 | } | ||
209 | |||
210 | void Engine::clearData(Data *d) { | ||
211 | d->i = d->fraction.numerator = d->fraction.denominator = 0; | ||
212 | d->dbl = 0; | ||
213 | } | ||
214 | |||
diff --git a/noncore/tools/calc2/engine.h b/noncore/tools/calc2/engine.h new file mode 100644 index 0000000..15c9aa1 --- a/dev/null +++ b/noncore/tools/calc2/engine.h | |||
@@ -0,0 +1,111 @@ | |||
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 | #ifndef ENGINE_H | ||
22 | #define ENGINE_H | ||
23 | |||
24 | #include <qwidget.h> | ||
25 | #include <qstack.h>// Instruction stack | ||
26 | #include <qstring.h>// Display | ||
27 | #include "instruction.h" | ||
28 | |||
29 | // Possible states | ||
30 | enum State { | ||
31 | sStart,// start inputting a new number | ||
32 | sAppend,// continue inputting a number | ||
33 | sError | ||
34 | }; | ||
35 | |||
36 | // State machine | ||
37 | class Engine:public QWidget { | ||
38 | |||
39 | Q_OBJECT | ||
40 | public: | ||
41 | Engine (QWidget * parent = 0, const char *name = 0):QWidget (parent, name) { | ||
42 | hardReset(); | ||
43 | setRepresentation(rDec); | ||
44 | }; | ||
45 | |||
46 | ~Engine () { }; | ||
47 | |||
48 | void immediateInstruction (Instruction *); | ||
49 | void pushInstruction (Instruction *); | ||
50 | void eval (); | ||
51 | |||
52 | void pushValue (char); | ||
53 | void del (); | ||
54 | |||
55 | void openBrace (); | ||
56 | void closeBrace (); | ||
57 | |||
58 | void softReset () {// clears the number being inputted | ||
59 | decimalPlaces = -1; | ||
60 | clearData(&num); | ||
61 | displayData(num); | ||
62 | state = sStart; | ||
63 | }; | ||
64 | void hardReset () {// a "real" reset of the stack | ||
65 | stack.clear (); | ||
66 | memClear(); | ||
67 | braces = 0; | ||
68 | softReset (); | ||
69 | }; | ||
70 | |||
71 | void memSave () { | ||
72 | mem = num; | ||
73 | }; | ||
74 | void memRecall () { | ||
75 | num = mem; | ||
76 | state = sStart; | ||
77 | displayData(num); | ||
78 | }; | ||
79 | void memClear () { | ||
80 | clearData(&mem); | ||
81 | }; | ||
82 | |||
83 | // rFraction will require a special display enabled here | ||
84 | void setRepresentation(Representation); | ||
85 | |||
86 | // you dont want to call this | ||
87 | void decBraces(void){ braces--; }; | ||
88 | |||
89 | private: | ||
90 | void displayData(Data d); | ||
91 | void clearData(Data *d); | ||
92 | int calcBase(); | ||
93 | Data evalStack (Data, bool); | ||
94 | Data num,mem; | ||
95 | State state; | ||
96 | QStack < Instruction > stack; | ||
97 | Representation currentRep; | ||
98 | int braces, decimalPlaces; // count of finishing 0's in num | ||
99 | QString displayString; // saves instatiating it over and over | ||
100 | |||
101 | signals: | ||
102 | void display(const QString &); | ||
103 | void display(double); // could get rid of this and | ||
104 | // use a QLabel instead. | ||
105 | void setHexMode(); | ||
106 | void setBinMode(); | ||
107 | void setDecMode(); | ||
108 | void setOctMode(); | ||
109 | }; | ||
110 | |||
111 | #endif | ||
diff --git a/noncore/tools/calc2/instruction.h b/noncore/tools/calc2/instruction.h new file mode 100644 index 0000000..6077bf0 --- a/dev/null +++ b/noncore/tools/calc2/instruction.h | |||
@@ -0,0 +1,69 @@ | |||
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 INSTRUCTION_H | ||
21 | #define INSTRUCTION_H | ||
22 | |||
23 | /* Internal representation of data | ||
24 | The first four types indicate an int, | ||
25 | that is, Data.i, and are incompatible | ||
26 | with the other two types. | ||
27 | |||
28 | - Plugin is responsible for telling engine | ||
29 | which Rep to use at any given time | ||
30 | - Instructions from that plugin only | ||
31 | have to handle that representation | ||
32 | - Engine is responsible for error-checking | ||
33 | according to its current rep and display */ | ||
34 | enum Representation { | ||
35 | rBin, | ||
36 | rOct, | ||
37 | rDec, | ||
38 | rHex, | ||
39 | rDouble, | ||
40 | rFraction | ||
41 | }; | ||
42 | |||
43 | // An atom of data | ||
44 | union Data { | ||
45 | int i; | ||
46 | double dbl; | ||
47 | struct Fraction { | ||
48 | int numerator, denominator; | ||
49 | } fraction; | ||
50 | }; | ||
51 | |||
52 | // Instruction base class | ||
53 | class Instruction { | ||
54 | public: | ||
55 | Instruction (int p = 0) { | ||
56 | precedence = p; | ||
57 | }; | ||
58 | |||
59 | virtual ~ Instruction () {}; | ||
60 | |||
61 | virtual Data eval(Data) = 0; | ||
62 | void setRep(Representation r) { rep = r; }; | ||
63 | |||
64 | Representation rep; | ||
65 | Data acc; | ||
66 | int precedence; | ||
67 | }; | ||
68 | |||
69 | #endif | ||
diff --git a/noncore/tools/calc2/main.cpp b/noncore/tools/calc2/main.cpp new file mode 100644 index 0000000..ebfcc28 --- a/dev/null +++ b/noncore/tools/calc2/main.cpp | |||
@@ -0,0 +1,34 @@ | |||
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 | #include <qpe/qpeapplication.h> | ||
21 | #include "calc.h" | ||
22 | |||
23 | int main (int argc, char **argv) | ||
24 | { | ||
25 | QPEApplication a (argc, argv); | ||
26 | |||
27 | calc mw; | ||
28 | |||
29 | QPEApplication::setInputMethodHint (&mw, QPEApplication::AlwaysOff); | ||
30 | mw.setCaption (calc::tr ("Calculator")); | ||
31 | a.showMainWidget (&mw); | ||
32 | |||
33 | return a.exec (); | ||
34 | } | ||
diff --git a/noncore/tools/calc2/plugininterface.h b/noncore/tools/calc2/plugininterface.h new file mode 100644 index 0000000..df6db9d --- a/dev/null +++ b/noncore/tools/calc2/plugininterface.h | |||
@@ -0,0 +1,45 @@ | |||
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 | #ifndef CALCINTERFACE_H | ||
22 | #define CALCINTERFACE_H | ||
23 | |||
24 | #include <qnamespace.h> | ||
25 | #include <qstring.h> | ||
26 | #include <qlcdnumber.h> | ||
27 | #include <qpe/qcom.h> | ||
28 | |||
29 | #include "engine.h" | ||
30 | |||
31 | #ifndef QT_NO_COMPONENT | ||
32 | // {3CE88B66-B3FD-4580-9D04-77338A31A667} | ||
33 | #ifndef IID_Calc | ||
34 | #define IID_Calc QUuid( 0x3ce88b66, 0xb3fd, 0x4580, 0x9d, 0x04, 0x77, 0x33, 0x8a, 0x31, 0xa6, 0x67) | ||
35 | #endif | ||
36 | #endif | ||
37 | |||
38 | class QWidget; | ||
39 | class QObject; | ||
40 | |||
41 | struct CalcInterface:public QUnknownInterface { | ||
42 | virtual QWidget *getPlugin (Engine *e, QWidget * parent) = 0; | ||
43 | }; | ||
44 | |||
45 | #endif | ||
diff --git a/noncore/tools/calc2/simple/README b/noncore/tools/calc2/simple/README new file mode 100644 index 0000000..37acb64 --- a/dev/null +++ b/noncore/tools/calc2/simple/README | |||
@@ -0,0 +1 @@ | |||
A simple interface with no operator precedence. | |||
diff --git a/noncore/tools/calc2/simple/simple.pro b/noncore/tools/calc2/simple/simple.pro new file mode 100644 index 0000000..92378a6 --- a/dev/null +++ b/noncore/tools/calc2/simple/simple.pro | |||
@@ -0,0 +1,14 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG -= moc | ||
3 | CONFIG += qt release | ||
4 | |||
5 | # Input | ||
6 | INTERFACES += simple.ui | ||
7 | HEADERS = simpleimpl.h simplefactory.h stdinstructions.h | ||
8 | SOURCES = simpleimpl.cpp simplefactory.cpp | ||
9 | |||
10 | INCLUDEPATH += $(QPEDIR)/include \ | ||
11 | $(QPEDIR)/calc2 | ||
12 | DEPENDPATH += $(QPEDIR)/include | ||
13 | |||
14 | DESTDIR = $(QPEDIR)/plugins/calculator | ||
diff --git a/noncore/tools/calc2/simple/simple.ui b/noncore/tools/calc2/simple/simple.ui new file mode 100644 index 0000000..af12905 --- a/dev/null +++ b/noncore/tools/calc2/simple/simple.ui | |||
@@ -0,0 +1,704 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>FormSimple</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>FormSimple</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>73</x> | ||
13 | <y>0</y> | ||
14 | <width>240</width> | ||
15 | <height>320</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>sizePolicy</name> | ||
20 | <sizepolicy> | ||
21 | <hsizetype>4</hsizetype> | ||
22 | <vsizetype>4</vsizetype> | ||
23 | </sizepolicy> | ||
24 | </property> | ||
25 | <property stdset="1"> | ||
26 | <name>maximumSize</name> | ||
27 | <size> | ||
28 | <width>240</width> | ||
29 | <height>320</height> | ||
30 | </size> | ||
31 | </property> | ||
32 | <property stdset="1"> | ||
33 | <name>baseSize</name> | ||
34 | <size> | ||
35 | <width>240</width> | ||
36 | <height>240</height> | ||
37 | </size> | ||
38 | </property> | ||
39 | <property stdset="1"> | ||
40 | <name>caption</name> | ||
41 | <string>Simple</string> | ||
42 | </property> | ||
43 | <grid> | ||
44 | <property stdset="1"> | ||
45 | <name>margin</name> | ||
46 | <number>0</number> | ||
47 | </property> | ||
48 | <property stdset="1"> | ||
49 | <name>spacing</name> | ||
50 | <number>0</number> | ||
51 | </property> | ||
52 | <widget row="4" column="2" > | ||
53 | <class>QPushButton</class> | ||
54 | <property stdset="1"> | ||
55 | <name>name</name> | ||
56 | <cstring>PBEval</cstring> | ||
57 | </property> | ||
58 | <property stdset="1"> | ||
59 | <name>sizePolicy</name> | ||
60 | <sizepolicy> | ||
61 | <hsizetype>4</hsizetype> | ||
62 | <vsizetype>4</vsizetype> | ||
63 | </sizepolicy> | ||
64 | </property> | ||
65 | <property stdset="1"> | ||
66 | <name>maximumSize</name> | ||
67 | <size> | ||
68 | <width>160</width> | ||
69 | <height>80</height> | ||
70 | </size> | ||
71 | </property> | ||
72 | <property stdset="1"> | ||
73 | <name>text</name> | ||
74 | <string>=</string> | ||
75 | </property> | ||
76 | </widget> | ||
77 | <widget row="2" column="1" > | ||
78 | <class>QPushButton</class> | ||
79 | <property stdset="1"> | ||
80 | <name>name</name> | ||
81 | <cstring>PB5</cstring> | ||
82 | </property> | ||
83 | <property stdset="1"> | ||
84 | <name>sizePolicy</name> | ||
85 | <sizepolicy> | ||
86 | <hsizetype>4</hsizetype> | ||
87 | <vsizetype>4</vsizetype> | ||
88 | </sizepolicy> | ||
89 | </property> | ||
90 | <property stdset="1"> | ||
91 | <name>maximumSize</name> | ||
92 | <size> | ||
93 | <width>80</width> | ||
94 | <height>80</height> | ||
95 | </size> | ||
96 | </property> | ||
97 | <property stdset="1"> | ||
98 | <name>text</name> | ||
99 | <string>5</string> | ||
100 | </property> | ||
101 | </widget> | ||
102 | <widget row="4" column="0" > | ||
103 | <class>QPushButton</class> | ||
104 | <property stdset="1"> | ||
105 | <name>name</name> | ||
106 | <cstring>PBDecimal</cstring> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>sizePolicy</name> | ||
110 | <sizepolicy> | ||
111 | <hsizetype>4</hsizetype> | ||
112 | <vsizetype>4</vsizetype> | ||
113 | </sizepolicy> | ||
114 | </property> | ||
115 | <property stdset="1"> | ||
116 | <name>maximumSize</name> | ||
117 | <size> | ||
118 | <width>80</width> | ||
119 | <height>80</height> | ||
120 | </size> | ||
121 | </property> | ||
122 | <property stdset="1"> | ||
123 | <name>text</name> | ||
124 | <string>.</string> | ||
125 | </property> | ||
126 | </widget> | ||
127 | <widget row="3" column="2" > | ||
128 | <class>QPushButton</class> | ||
129 | <property stdset="1"> | ||
130 | <name>name</name> | ||
131 | <cstring>PB3</cstring> | ||
132 | </property> | ||
133 | <property stdset="1"> | ||
134 | <name>sizePolicy</name> | ||
135 | <sizepolicy> | ||
136 | <hsizetype>4</hsizetype> | ||
137 | <vsizetype>4</vsizetype> | ||
138 | </sizepolicy> | ||
139 | </property> | ||
140 | <property stdset="1"> | ||
141 | <name>maximumSize</name> | ||
142 | <size> | ||
143 | <width>80</width> | ||
144 | <height>80</height> | ||
145 | </size> | ||
146 | </property> | ||
147 | <property stdset="1"> | ||
148 | <name>text</name> | ||
149 | <string>3</string> | ||
150 | </property> | ||
151 | </widget> | ||
152 | <widget row="3" column="1" > | ||
153 | <class>QPushButton</class> | ||
154 | <property stdset="1"> | ||
155 | <name>name</name> | ||
156 | <cstring>PB2</cstring> | ||
157 | </property> | ||
158 | <property stdset="1"> | ||
159 | <name>sizePolicy</name> | ||
160 | <sizepolicy> | ||
161 | <hsizetype>4</hsizetype> | ||
162 | <vsizetype>4</vsizetype> | ||
163 | </sizepolicy> | ||
164 | </property> | ||
165 | <property stdset="1"> | ||
166 | <name>maximumSize</name> | ||
167 | <size> | ||
168 | <width>80</width> | ||
169 | <height>80</height> | ||
170 | </size> | ||
171 | </property> | ||
172 | <property stdset="1"> | ||
173 | <name>text</name> | ||
174 | <string>2</string> | ||
175 | </property> | ||
176 | </widget> | ||
177 | <widget row="2" column="0" > | ||
178 | <class>QPushButton</class> | ||
179 | <property stdset="1"> | ||
180 | <name>name</name> | ||
181 | <cstring>PB4</cstring> | ||
182 | </property> | ||
183 | <property stdset="1"> | ||
184 | <name>sizePolicy</name> | ||
185 | <sizepolicy> | ||
186 | <hsizetype>4</hsizetype> | ||
187 | <vsizetype>4</vsizetype> | ||
188 | </sizepolicy> | ||
189 | </property> | ||
190 | <property stdset="1"> | ||
191 | <name>maximumSize</name> | ||
192 | <size> | ||
193 | <width>80</width> | ||
194 | <height>80</height> | ||
195 | </size> | ||
196 | </property> | ||
197 | <property stdset="1"> | ||
198 | <name>text</name> | ||
199 | <string>4</string> | ||
200 | </property> | ||
201 | </widget> | ||
202 | <widget row="2" column="2" > | ||
203 | <class>QPushButton</class> | ||
204 | <property stdset="1"> | ||
205 | <name>name</name> | ||
206 | <cstring>PB6</cstring> | ||
207 | </property> | ||
208 | <property stdset="1"> | ||
209 | <name>sizePolicy</name> | ||
210 | <sizepolicy> | ||
211 | <hsizetype>4</hsizetype> | ||
212 | <vsizetype>4</vsizetype> | ||
213 | </sizepolicy> | ||
214 | </property> | ||
215 | <property stdset="1"> | ||
216 | <name>maximumSize</name> | ||
217 | <size> | ||
218 | <width>80</width> | ||
219 | <height>80</height> | ||
220 | </size> | ||
221 | </property> | ||
222 | <property stdset="1"> | ||
223 | <name>text</name> | ||
224 | <string>6</string> | ||
225 | </property> | ||
226 | </widget> | ||
227 | <widget row="3" column="3" > | ||
228 | <class>QPushButton</class> | ||
229 | <property stdset="1"> | ||
230 | <name>name</name> | ||
231 | <cstring>PBMul</cstring> | ||
232 | </property> | ||
233 | <property stdset="1"> | ||
234 | <name>sizePolicy</name> | ||
235 | <sizepolicy> | ||
236 | <hsizetype>4</hsizetype> | ||
237 | <vsizetype>4</vsizetype> | ||
238 | </sizepolicy> | ||
239 | </property> | ||
240 | <property stdset="1"> | ||
241 | <name>maximumSize</name> | ||
242 | <size> | ||
243 | <width>80</width> | ||
244 | <height>80</height> | ||
245 | </size> | ||
246 | </property> | ||
247 | <property stdset="1"> | ||
248 | <name>text</name> | ||
249 | <string>*</string> | ||
250 | </property> | ||
251 | </widget> | ||
252 | <widget row="2" column="3" > | ||
253 | <class>QPushButton</class> | ||
254 | <property stdset="1"> | ||
255 | <name>name</name> | ||
256 | <cstring>PBSub</cstring> | ||
257 | </property> | ||
258 | <property stdset="1"> | ||
259 | <name>sizePolicy</name> | ||
260 | <sizepolicy> | ||
261 | <hsizetype>4</hsizetype> | ||
262 | <vsizetype>4</vsizetype> | ||
263 | </sizepolicy> | ||
264 | </property> | ||
265 | <property stdset="1"> | ||
266 | <name>maximumSize</name> | ||
267 | <size> | ||
268 | <width>80</width> | ||
269 | <height>80</height> | ||
270 | </size> | ||
271 | </property> | ||
272 | <property stdset="1"> | ||
273 | <name>text</name> | ||
274 | <string>-</string> | ||
275 | </property> | ||
276 | </widget> | ||
277 | <widget row="1" column="3" > | ||
278 | <class>QPushButton</class> | ||
279 | <property stdset="1"> | ||
280 | <name>name</name> | ||
281 | <cstring>PBAdd</cstring> | ||
282 | </property> | ||
283 | <property stdset="1"> | ||
284 | <name>sizePolicy</name> | ||
285 | <sizepolicy> | ||
286 | <hsizetype>4</hsizetype> | ||
287 | <vsizetype>4</vsizetype> | ||
288 | </sizepolicy> | ||
289 | </property> | ||
290 | <property stdset="1"> | ||
291 | <name>maximumSize</name> | ||
292 | <size> | ||
293 | <width>80</width> | ||
294 | <height>80</height> | ||
295 | </size> | ||
296 | </property> | ||
297 | <property stdset="1"> | ||
298 | <name>text</name> | ||
299 | <string>+</string> | ||
300 | </property> | ||
301 | </widget> | ||
302 | <widget row="1" column="2" > | ||
303 | <class>QPushButton</class> | ||
304 | <property stdset="1"> | ||
305 | <name>name</name> | ||
306 | <cstring>PB9</cstring> | ||
307 | </property> | ||
308 | <property stdset="1"> | ||
309 | <name>sizePolicy</name> | ||
310 | <sizepolicy> | ||
311 | <hsizetype>4</hsizetype> | ||
312 | <vsizetype>4</vsizetype> | ||
313 | </sizepolicy> | ||
314 | </property> | ||
315 | <property stdset="1"> | ||
316 | <name>maximumSize</name> | ||
317 | <size> | ||
318 | <width>80</width> | ||
319 | <height>80</height> | ||
320 | </size> | ||
321 | </property> | ||
322 | <property stdset="1"> | ||
323 | <name>text</name> | ||
324 | <string>9</string> | ||
325 | </property> | ||
326 | </widget> | ||
327 | <widget row="1" column="0" > | ||
328 | <class>QPushButton</class> | ||
329 | <property stdset="1"> | ||
330 | <name>name</name> | ||
331 | <cstring>PB7</cstring> | ||
332 | </property> | ||
333 | <property stdset="1"> | ||
334 | <name>enabled</name> | ||
335 | <bool>true</bool> | ||
336 | </property> | ||
337 | <property stdset="1"> | ||
338 | <name>sizePolicy</name> | ||
339 | <sizepolicy> | ||
340 | <hsizetype>4</hsizetype> | ||
341 | <vsizetype>4</vsizetype> | ||
342 | </sizepolicy> | ||
343 | </property> | ||
344 | <property stdset="1"> | ||
345 | <name>maximumSize</name> | ||
346 | <size> | ||
347 | <width>80</width> | ||
348 | <height>80</height> | ||
349 | </size> | ||
350 | </property> | ||
351 | <property stdset="1"> | ||
352 | <name>text</name> | ||
353 | <string>7</string> | ||
354 | </property> | ||
355 | </widget> | ||
356 | <widget row="3" column="0" > | ||
357 | <class>QPushButton</class> | ||
358 | <property stdset="1"> | ||
359 | <name>name</name> | ||
360 | <cstring>PB1</cstring> | ||
361 | </property> | ||
362 | <property stdset="1"> | ||
363 | <name>sizePolicy</name> | ||
364 | <sizepolicy> | ||
365 | <hsizetype>4</hsizetype> | ||
366 | <vsizetype>4</vsizetype> | ||
367 | </sizepolicy> | ||
368 | </property> | ||
369 | <property stdset="1"> | ||
370 | <name>maximumSize</name> | ||
371 | <size> | ||
372 | <width>80</width> | ||
373 | <height>80</height> | ||
374 | </size> | ||
375 | </property> | ||
376 | <property stdset="1"> | ||
377 | <name>text</name> | ||
378 | <string>1</string> | ||
379 | </property> | ||
380 | </widget> | ||
381 | <widget row="4" column="1" > | ||
382 | <class>QPushButton</class> | ||
383 | <property stdset="1"> | ||
384 | <name>name</name> | ||
385 | <cstring>PB0</cstring> | ||
386 | </property> | ||
387 | <property stdset="1"> | ||
388 | <name>sizePolicy</name> | ||
389 | <sizepolicy> | ||
390 | <hsizetype>4</hsizetype> | ||
391 | <vsizetype>4</vsizetype> | ||
392 | </sizepolicy> | ||
393 | </property> | ||
394 | <property stdset="1"> | ||
395 | <name>maximumSize</name> | ||
396 | <size> | ||
397 | <width>160</width> | ||
398 | <height>80</height> | ||
399 | </size> | ||
400 | </property> | ||
401 | <property stdset="1"> | ||
402 | <name>text</name> | ||
403 | <string>0</string> | ||
404 | </property> | ||
405 | </widget> | ||
406 | <widget row="4" column="3" > | ||
407 | <class>QPushButton</class> | ||
408 | <property stdset="1"> | ||
409 | <name>name</name> | ||
410 | <cstring>PBDiv</cstring> | ||
411 | </property> | ||
412 | <property stdset="1"> | ||
413 | <name>sizePolicy</name> | ||
414 | <sizepolicy> | ||
415 | <hsizetype>4</hsizetype> | ||
416 | <vsizetype>4</vsizetype> | ||
417 | </sizepolicy> | ||
418 | </property> | ||
419 | <property stdset="1"> | ||
420 | <name>maximumSize</name> | ||
421 | <size> | ||
422 | <width>80</width> | ||
423 | <height>80</height> | ||
424 | </size> | ||
425 | </property> | ||
426 | <property stdset="1"> | ||
427 | <name>text</name> | ||
428 | <string>/</string> | ||
429 | </property> | ||
430 | <property stdset="1"> | ||
431 | <name>autoRepeat</name> | ||
432 | <bool>true</bool> | ||
433 | </property> | ||
434 | </widget> | ||
435 | <widget row="1" column="1" > | ||
436 | <class>QPushButton</class> | ||
437 | <property stdset="1"> | ||
438 | <name>name</name> | ||
439 | <cstring>PB8</cstring> | ||
440 | </property> | ||
441 | <property stdset="1"> | ||
442 | <name>sizePolicy</name> | ||
443 | <sizepolicy> | ||
444 | <hsizetype>4</hsizetype> | ||
445 | <vsizetype>4</vsizetype> | ||
446 | </sizepolicy> | ||
447 | </property> | ||
448 | <property stdset="1"> | ||
449 | <name>maximumSize</name> | ||
450 | <size> | ||
451 | <width>80</width> | ||
452 | <height>80</height> | ||
453 | </size> | ||
454 | </property> | ||
455 | <property stdset="1"> | ||
456 | <name>text</name> | ||
457 | <string>8</string> | ||
458 | </property> | ||
459 | </widget> | ||
460 | <widget row="0" column="0" > | ||
461 | <class>QPushButton</class> | ||
462 | <property stdset="1"> | ||
463 | <name>name</name> | ||
464 | <cstring>PBMPlus</cstring> | ||
465 | </property> | ||
466 | <property stdset="1"> | ||
467 | <name>sizePolicy</name> | ||
468 | <sizepolicy> | ||
469 | <hsizetype>4</hsizetype> | ||
470 | <vsizetype>4</vsizetype> | ||
471 | </sizepolicy> | ||
472 | </property> | ||
473 | <property stdset="1"> | ||
474 | <name>maximumSize</name> | ||
475 | <size> | ||
476 | <width>80</width> | ||
477 | <height>80</height> | ||
478 | </size> | ||
479 | </property> | ||
480 | <property stdset="1"> | ||
481 | <name>text</name> | ||
482 | <string>M+</string> | ||
483 | </property> | ||
484 | </widget> | ||
485 | <widget row="0" column="3" > | ||
486 | <class>QPushButton</class> | ||
487 | <property stdset="1"> | ||
488 | <name>name</name> | ||
489 | <cstring>PBCE</cstring> | ||
490 | </property> | ||
491 | <property stdset="1"> | ||
492 | <name>sizePolicy</name> | ||
493 | <sizepolicy> | ||
494 | <hsizetype>4</hsizetype> | ||
495 | <vsizetype>4</vsizetype> | ||
496 | </sizepolicy> | ||
497 | </property> | ||
498 | <property stdset="1"> | ||
499 | <name>maximumSize</name> | ||
500 | <size> | ||
501 | <width>80</width> | ||
502 | <height>80</height> | ||
503 | </size> | ||
504 | </property> | ||
505 | <property stdset="1"> | ||
506 | <name>text</name> | ||
507 | <string>CE</string> | ||
508 | </property> | ||
509 | </widget> | ||
510 | <widget row="0" column="2" > | ||
511 | <class>QPushButton</class> | ||
512 | <property stdset="1"> | ||
513 | <name>name</name> | ||
514 | <cstring>PBMC</cstring> | ||
515 | </property> | ||
516 | <property stdset="1"> | ||
517 | <name>sizePolicy</name> | ||
518 | <sizepolicy> | ||
519 | <hsizetype>4</hsizetype> | ||
520 | <vsizetype>4</vsizetype> | ||
521 | </sizepolicy> | ||
522 | </property> | ||
523 | <property stdset="1"> | ||
524 | <name>maximumSize</name> | ||
525 | <size> | ||
526 | <width>80</width> | ||
527 | <height>80</height> | ||
528 | </size> | ||
529 | </property> | ||
530 | <property stdset="1"> | ||
531 | <name>text</name> | ||
532 | <string>MC</string> | ||
533 | </property> | ||
534 | </widget> | ||
535 | <widget row="0" column="1" > | ||
536 | <class>QPushButton</class> | ||
537 | <property stdset="1"> | ||
538 | <name>name</name> | ||
539 | <cstring>PBMR</cstring> | ||
540 | </property> | ||
541 | <property stdset="1"> | ||
542 | <name>sizePolicy</name> | ||
543 | <sizepolicy> | ||
544 | <hsizetype>4</hsizetype> | ||
545 | <vsizetype>4</vsizetype> | ||
546 | </sizepolicy> | ||
547 | </property> | ||
548 | <property stdset="1"> | ||
549 | <name>maximumSize</name> | ||
550 | <size> | ||
551 | <width>80</width> | ||
552 | <height>80</height> | ||
553 | </size> | ||
554 | </property> | ||
555 | <property stdset="1"> | ||
556 | <name>text</name> | ||
557 | <string>MR</string> | ||
558 | </property> | ||
559 | </widget> | ||
560 | </grid> | ||
561 | </widget> | ||
562 | <connections> | ||
563 | <connection> | ||
564 | <sender>PB0</sender> | ||
565 | <signal>clicked()</signal> | ||
566 | <receiver>FormSimple</receiver> | ||
567 | <slot>val0Clicked()</slot> | ||
568 | </connection> | ||
569 | <connection> | ||
570 | <sender>PB1</sender> | ||
571 | <signal>clicked()</signal> | ||
572 | <receiver>FormSimple</receiver> | ||
573 | <slot>val1Clicked()</slot> | ||
574 | </connection> | ||
575 | <connection> | ||
576 | <sender>PB2</sender> | ||
577 | <signal>clicked()</signal> | ||
578 | <receiver>FormSimple</receiver> | ||
579 | <slot>val2Clicked()</slot> | ||
580 | </connection> | ||
581 | <connection> | ||
582 | <sender>PB3</sender> | ||
583 | <signal>clicked()</signal> | ||
584 | <receiver>FormSimple</receiver> | ||
585 | <slot>val3Clicked()</slot> | ||
586 | </connection> | ||
587 | <connection> | ||
588 | <sender>PB4</sender> | ||
589 | <signal>clicked()</signal> | ||
590 | <receiver>FormSimple</receiver> | ||
591 | <slot>val4Clicked()</slot> | ||
592 | </connection> | ||
593 | <connection> | ||
594 | <sender>PB5</sender> | ||
595 | <signal>clicked()</signal> | ||
596 | <receiver>FormSimple</receiver> | ||
597 | <slot>val5Clicked()</slot> | ||
598 | </connection> | ||
599 | <connection> | ||
600 | <sender>PB6</sender> | ||
601 | <signal>clicked()</signal> | ||
602 | <receiver>FormSimple</receiver> | ||
603 | <slot>val6Clicked()</slot> | ||
604 | </connection> | ||
605 | <connection> | ||
606 | <sender>PB7</sender> | ||
607 | <signal>clicked()</signal> | ||
608 | <receiver>FormSimple</receiver> | ||
609 | <slot>val7Clicked()</slot> | ||
610 | </connection> | ||
611 | <connection> | ||
612 | <sender>PB8</sender> | ||
613 | <signal>clicked()</signal> | ||
614 | <receiver>FormSimple</receiver> | ||
615 | <slot>val8Clicked()</slot> | ||
616 | </connection> | ||
617 | <connection> | ||
618 | <sender>PB9</sender> | ||
619 | <signal>clicked()</signal> | ||
620 | <receiver>FormSimple</receiver> | ||
621 | <slot>val9Clicked()</slot> | ||
622 | </connection> | ||
623 | <connection> | ||
624 | <sender>PBSub</sender> | ||
625 | <signal>clicked()</signal> | ||
626 | <receiver>FormSimple</receiver> | ||
627 | <slot>subClicked()</slot> | ||
628 | </connection> | ||
629 | <connection> | ||
630 | <sender>PBMul</sender> | ||
631 | <signal>clicked()</signal> | ||
632 | <receiver>FormSimple</receiver> | ||
633 | <slot>mulClicked()</slot> | ||
634 | </connection> | ||
635 | <connection> | ||
636 | <sender>PBDiv</sender> | ||
637 | <signal>clicked()</signal> | ||
638 | <receiver>FormSimple</receiver> | ||
639 | <slot>divClicked()</slot> | ||
640 | </connection> | ||
641 | <connection> | ||
642 | <sender>PBDecimal</sender> | ||
643 | <signal>clicked()</signal> | ||
644 | <receiver>FormSimple</receiver> | ||
645 | <slot>decimalClicked()</slot> | ||
646 | </connection> | ||
647 | <connection> | ||
648 | <sender>PBEval</sender> | ||
649 | <signal>clicked()</signal> | ||
650 | <receiver>FormSimple</receiver> | ||
651 | <slot>evalClicked()</slot> | ||
652 | </connection> | ||
653 | <connection> | ||
654 | <sender>PBMC</sender> | ||
655 | <signal>clicked()</signal> | ||
656 | <receiver>FormSimple</receiver> | ||
657 | <slot>MCClicked()</slot> | ||
658 | </connection> | ||
659 | <connection> | ||
660 | <sender>PBMPlus</sender> | ||
661 | <signal>clicked()</signal> | ||
662 | <receiver>FormSimple</receiver> | ||
663 | <slot>MPlusClicked()</slot> | ||
664 | </connection> | ||
665 | <connection> | ||
666 | <sender>PBMR</sender> | ||
667 | <signal>clicked()</signal> | ||
668 | <receiver>FormSimple</receiver> | ||
669 | <slot>MRClicked()</slot> | ||
670 | </connection> | ||
671 | <connection> | ||
672 | <sender>PBAdd</sender> | ||
673 | <signal>clicked()</signal> | ||
674 | <receiver>FormSimple</receiver> | ||
675 | <slot>addClicked()</slot> | ||
676 | </connection> | ||
677 | <connection> | ||
678 | <sender>PBCE</sender> | ||
679 | <signal>clicked()</signal> | ||
680 | <receiver>FormSimple</receiver> | ||
681 | <slot>CEClicked()</slot> | ||
682 | </connection> | ||
683 | <slot access="public">CEClicked()</slot> | ||
684 | <slot access="public">MCClicked()</slot> | ||
685 | <slot access="public">MPlusClicked()</slot> | ||
686 | <slot access="public">MRClicked()</slot> | ||
687 | <slot access="public">addClicked()</slot> | ||
688 | <slot access="public">decimalClicked()</slot> | ||
689 | <slot access="public">divClicked()</slot> | ||
690 | <slot access="public">evalClicked()</slot> | ||
691 | <slot access="public">mulClicked()</slot> | ||
692 | <slot access="public">subClicked()</slot> | ||
693 | <slot access="public">val0Clicked()</slot> | ||
694 | <slot access="public">val1Clicked()</slot> | ||
695 | <slot access="public">val2Clicked()</slot> | ||
696 | <slot access="public">val3Clicked()</slot> | ||
697 | <slot access="public">val4Clicked()</slot> | ||
698 | <slot access="public">val5Clicked()</slot> | ||
699 | <slot access="public">val6Clicked()</slot> | ||
700 | <slot access="public">val7Clicked()</slot> | ||
701 | <slot access="public">val8Clicked()</slot> | ||
702 | <slot access="public">val9Clicked()</slot> | ||
703 | </connections> | ||
704 | </UI> | ||
diff --git a/noncore/tools/calc2/simple/simplefactory.cpp b/noncore/tools/calc2/simple/simplefactory.cpp new file mode 100644 index 0000000..515418f --- a/dev/null +++ b/noncore/tools/calc2/simple/simplefactory.cpp | |||
@@ -0,0 +1,51 @@ | |||
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 | ** 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 | **********************************************************************/ | ||
22 | |||
23 | #include "simplefactory.h" | ||
24 | #include "simpleimpl.h" | ||
25 | #include <engine.h> | ||
26 | |||
27 | QWidget *SimpleInterface::getPlugin ( Engine *e, QWidget *parent ) { | ||
28 | if ( !input ) | ||
29 | input = new FormSimpleImpl ( e, parent ); | ||
30 | return input; | ||
31 | } | ||
32 | |||
33 | #ifndef QT_NO_COMPONENT | ||
34 | QRESULT SimpleInterface::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
35 | { | ||
36 | *iface = 0; | ||
37 | if ( uuid == IID_QUnknown ) | ||
38 | *iface = this; | ||
39 | else if ( uuid == IID_Calc ) | ||
40 | *iface = this; | ||
41 | |||
42 | if ( *iface ) | ||
43 | (*iface)->addRef(); | ||
44 | return QS_OK; | ||
45 | } | ||
46 | |||
47 | Q_EXPORT_INTERFACE() | ||
48 | { | ||
49 | Q_CREATE_INSTANCE( SimpleInterface ) | ||
50 | } | ||
51 | #endif | ||
diff --git a/noncore/tools/calc2/simple/simplefactory.h b/noncore/tools/calc2/simple/simplefactory.h new file mode 100644 index 0000000..e1022fd --- a/dev/null +++ b/noncore/tools/calc2/simple/simplefactory.h | |||
@@ -0,0 +1,46 @@ | |||
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 | #ifndef BINARYIMPL_H | ||
22 | #define BINARYIMPL_H | ||
23 | |||
24 | #include "simpleimpl.h" | ||
25 | #include <plugininterface.h> | ||
26 | #include <engine.h> | ||
27 | |||
28 | class SimpleInterface : public CalcInterface | ||
29 | { | ||
30 | public: | ||
31 | SimpleInterface(){input = 0;}; | ||
32 | virtual ~SimpleInterface(){}; | ||
33 | |||
34 | #ifndef QT_NO_COMPONENT | ||
35 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
36 | Q_REFCOUNT | ||
37 | #endif | ||
38 | |||
39 | QWidget *getPlugin( Engine *, QWidget *parent ); | ||
40 | |||
41 | private: | ||
42 | FormSimpleImpl *input; | ||
43 | ulong ref; | ||
44 | }; | ||
45 | |||
46 | #endif | ||
diff --git a/noncore/tools/calc2/simple/simpleimpl.cpp b/noncore/tools/calc2/simple/simpleimpl.cpp new file mode 100644 index 0000000..f71f000 --- a/dev/null +++ b/noncore/tools/calc2/simple/simpleimpl.cpp | |||
@@ -0,0 +1,120 @@ | |||
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 <qpushbutton.h> | ||
22 | #include <qlcdnumber.h> | ||
23 | |||
24 | #include "simpleimpl.h" | ||
25 | #include <stdinstructions.h> | ||
26 | |||
27 | void FormSimpleImpl::CEClicked() { | ||
28 | engine->hardReset(); | ||
29 | } | ||
30 | |||
31 | void FormSimpleImpl::MCClicked() { | ||
32 | engine->memClear(); | ||
33 | } | ||
34 | |||
35 | void FormSimpleImpl::MRClicked() { | ||
36 | engine->memRecall(); | ||
37 | } | ||
38 | |||
39 | void FormSimpleImpl::MPlusClicked() { | ||
40 | engine->memSave(); | ||
41 | } | ||
42 | |||
43 | void FormSimpleImpl::evalClicked() { | ||
44 | engine->eval(); | ||
45 | } | ||
46 | |||
47 | void FormSimpleImpl::addClicked () | ||
48 | { | ||
49 | engine->pushInstruction (new iAdd ()); | ||
50 | } | ||
51 | |||
52 | void FormSimpleImpl::subClicked () | ||
53 | { | ||
54 | engine->pushInstruction (new iSub ()); | ||
55 | } | ||
56 | |||
57 | void FormSimpleImpl::mulClicked () | ||
58 | { | ||
59 | engine->pushInstruction (new iMul ()); | ||
60 | } | ||
61 | |||
62 | void FormSimpleImpl::divClicked () | ||
63 | { | ||
64 | engine->pushInstruction (new iDiv ()); | ||
65 | } | ||
66 | |||
67 | void FormSimpleImpl::decimalClicked () | ||
68 | { | ||
69 | engine->pushValue ('.'); | ||
70 | } | ||
71 | |||
72 | void FormSimpleImpl::val1Clicked () | ||
73 | { | ||
74 | engine->pushValue ('1'); | ||
75 | } | ||
76 | |||
77 | void FormSimpleImpl::val2Clicked () | ||
78 | { | ||
79 | engine->pushValue ('2'); | ||
80 | } | ||
81 | |||
82 | void FormSimpleImpl::val3Clicked () | ||
83 | { | ||
84 | engine->pushValue ('3'); | ||
85 | } | ||
86 | |||
87 | void FormSimpleImpl::val4Clicked () | ||
88 | { | ||
89 | engine->pushValue ('4'); | ||
90 | } | ||
91 | |||
92 | void FormSimpleImpl::val5Clicked () | ||
93 | { | ||
94 | engine->pushValue ('5'); | ||
95 | } | ||
96 | |||
97 | void FormSimpleImpl::val6Clicked () | ||
98 | { | ||
99 | engine->pushValue ('6'); | ||
100 | } | ||
101 | |||
102 | void FormSimpleImpl::val7Clicked () | ||
103 | { | ||
104 | engine->pushValue ('7'); | ||
105 | } | ||
106 | |||
107 | void FormSimpleImpl::val8Clicked () | ||
108 | { | ||
109 | engine->pushValue ('8'); | ||
110 | } | ||
111 | |||
112 | void FormSimpleImpl::val9Clicked () | ||
113 | { | ||
114 | engine->pushValue ('9'); | ||
115 | } | ||
116 | |||
117 | void FormSimpleImpl::val0Clicked () | ||
118 | { | ||
119 | engine->pushValue ('0'); | ||
120 | } | ||
diff --git a/noncore/tools/calc2/simple/simpleimpl.h b/noncore/tools/calc2/simple/simpleimpl.h new file mode 100644 index 0000000..a2db154 --- a/dev/null +++ b/noncore/tools/calc2/simple/simpleimpl.h | |||
@@ -0,0 +1,65 @@ | |||
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 | #ifndef STANDARDIMPL_H | ||
22 | #define STANDARDIMPL_H | ||
23 | |||
24 | #include <qpe/qmath.h> | ||
25 | #include <qlcdnumber.h> | ||
26 | |||
27 | #include "simple.h" | ||
28 | #include "engine.h" | ||
29 | #include "instruction.h" | ||
30 | |||
31 | class FormSimpleImpl:public FormSimple { | ||
32 | Q_OBJECT | ||
33 | public: | ||
34 | FormSimpleImpl (Engine *e, QWidget * parent = 0, const char *name = 0) | ||
35 | :FormSimple (parent, name) {engine = e;engine->setRepresentation(rDouble);}; | ||
36 | |||
37 | ~FormSimpleImpl () { }; | ||
38 | |||
39 | private: | ||
40 | Engine *engine; | ||
41 | |||
42 | private slots: | ||
43 | void MPlusClicked(); | ||
44 | void MCClicked(); | ||
45 | void MRClicked(); | ||
46 | void CEClicked(); | ||
47 | void evalClicked(); | ||
48 | void addClicked (); | ||
49 | void decimalClicked (); | ||
50 | void divClicked (); | ||
51 | void mulClicked (); | ||
52 | void subClicked (); | ||
53 | void val0Clicked (); | ||
54 | void val1Clicked (); | ||
55 | void val2Clicked (); | ||
56 | void val3Clicked (); | ||
57 | void val4Clicked (); | ||
58 | void val5Clicked (); | ||
59 | void val6Clicked (); | ||
60 | void val7Clicked (); | ||
61 | void val8Clicked (); | ||
62 | void val9Clicked (); | ||
63 | }; | ||
64 | |||
65 | #endif | ||
diff --git a/noncore/tools/calc2/stdinstructions.h b/noncore/tools/calc2/stdinstructions.h new file mode 100644 index 0000000..a575968 --- a/dev/null +++ b/noncore/tools/calc2/stdinstructions.h | |||
@@ -0,0 +1,125 @@ | |||
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 | #ifndef STDINSTRUCTION_H | ||
22 | #define STDINSTRUCTION_H | ||
23 | |||
24 | #include <qpe/qmath.h> | ||
25 | #include "instruction.h" | ||
26 | |||
27 | // Useful instructions for plugin writers | ||
28 | // If you use them, take note of their precedence | ||
29 | class iAdd:public Instruction { | ||
30 | public: | ||
31 | iAdd ():Instruction (10) { }; | ||
32 | ~iAdd () { }; | ||
33 | Data eval (Data num) { | ||
34 | Data result; | ||
35 | switch (rep) { | ||
36 | case rDouble: | ||
37 | result.dbl = acc.dbl + num.dbl; | ||
38 | break; | ||
39 | default: | ||
40 | result.i = acc.i + num.i; | ||
41 | }; | ||
42 | return result; | ||
43 | }; | ||
44 | }; | ||
45 | class iSub:public Instruction { | ||
46 | public: | ||
47 | iSub ():Instruction (10) { }; | ||
48 | ~iSub () { }; | ||
49 | Data eval (Data num) { | ||
50 | Data result; | ||
51 | switch (rep) { | ||
52 | case rDouble: | ||
53 | result.dbl = acc.dbl - num.dbl; | ||
54 | break; | ||
55 | default: | ||
56 | result.i = acc.i - num.i; | ||
57 | }; | ||
58 | return result; | ||
59 | }; | ||
60 | }; | ||
61 | class iMul:public Instruction { | ||
62 | public: | ||
63 | iMul ():Instruction (20) { }; | ||
64 | ~iMul () { }; | ||
65 | Data eval (Data num) { | ||
66 | Data result; | ||
67 | switch (rep) { | ||
68 | case rDouble: | ||
69 | result.dbl = acc.dbl * num.dbl; | ||
70 | break; | ||
71 | default: | ||
72 | result.i = acc.i * num.i; | ||
73 | }; | ||
74 | return result; | ||
75 | }; | ||
76 | }; | ||
77 | class iDiv:public Instruction { | ||
78 | public: | ||
79 | iDiv ():Instruction (20) { }; | ||
80 | ~iDiv () { }; | ||
81 | Data eval (Data num) { | ||
82 | Data result; | ||
83 | switch (rep) { | ||
84 | case rDouble: | ||
85 | result.dbl = acc.dbl / num.dbl; | ||
86 | break; | ||
87 | default: | ||
88 | result.i = acc.i / num.i; | ||
89 | }; | ||
90 | return result; | ||
91 | }; | ||
92 | }; | ||
93 | |||
94 | // Immediate double instructions only | ||
95 | class iSin:public Instruction { | ||
96 | public: | ||
97 | iSin ():Instruction () { }; | ||
98 | ~iSin () { }; | ||
99 | Data eval (Data num) { | ||
100 | Data result; | ||
101 | result.dbl = qSin(num.dbl); | ||
102 | return result; | ||
103 | }; | ||
104 | }; | ||
105 | class iCos:public Instruction { | ||
106 | public: | ||
107 | iCos ():Instruction () { }; | ||
108 | ~iCos () { }; | ||
109 | Data eval (Data num) { | ||
110 | Data result; | ||
111 | result.dbl = qCos(num.dbl); | ||
112 | return result; | ||
113 | }; | ||
114 | }; | ||
115 | class iTan:public Instruction { | ||
116 | public: | ||
117 | iTan ():Instruction () { }; | ||
118 | ~iTan () {}; | ||
119 | Data eval (Data num) { | ||
120 | Data result; | ||
121 | result.dbl = qTan(num.dbl); | ||
122 | return result; | ||
123 | }; | ||
124 | }; | ||
125 | #endif | ||
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. | ||
diff --git a/noncore/tools/clock/.cvsignore b/noncore/tools/clock/.cvsignore new file mode 100644 index 0000000..6fe2396 --- a/dev/null +++ b/noncore/tools/clock/.cvsignore | |||
@@ -0,0 +1,2 @@ | |||
1 | moc_* | ||
2 | Makefile | ||
diff --git a/noncore/tools/clock/Makefile.in b/noncore/tools/clock/Makefile.in new file mode 100644 index 0000000..adda9e6 --- a/dev/null +++ b/noncore/tools/clock/Makefile.in | |||
@@ -0,0 +1,118 @@ | |||
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= clock | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =clock.h | ||
27 | SOURCES =clock.cpp \ | ||
28 | main.cpp | ||
29 | OBJECTS =clock.o \ | ||
30 | main.o | ||
31 | INTERFACES = | ||
32 | UICDECLS = | ||
33 | UICIMPLS = | ||
34 | SRCMOC =moc_clock.cpp | ||
35 | OBJMOC =moc_clock.o | ||
36 | |||
37 | |||
38 | ####### Implicit rules | ||
39 | |||
40 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
41 | |||
42 | .cpp.o: | ||
43 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
44 | |||
45 | .cxx.o: | ||
46 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
47 | |||
48 | .cc.o: | ||
49 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
50 | |||
51 | .C.o: | ||
52 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
53 | |||
54 | .c.o: | ||
55 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
56 | |||
57 | ####### Build rules | ||
58 | |||
59 | |||
60 | all: $(DESTDIR)$(TARGET) | ||
61 | |||
62 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
63 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
64 | |||
65 | moc: $(SRCMOC) | ||
66 | |||
67 | tmake: | ||
68 | tmake clock.pro | ||
69 | |||
70 | clean: | ||
71 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
72 | -rm -f *~ core | ||
73 | -rm -f allmoc.cpp | ||
74 | |||
75 | ####### Extension Modules | ||
76 | |||
77 | listpromodules: | ||
78 | @echo | ||
79 | |||
80 | listallmodules: | ||
81 | @echo | ||
82 | |||
83 | listaddonpromodules: | ||
84 | @echo | ||
85 | |||
86 | listaddonentmodules: | ||
87 | @echo | ||
88 | |||
89 | |||
90 | REQUIRES= | ||
91 | |||
92 | ####### Sub-libraries | ||
93 | |||
94 | |||
95 | ###### Combined headers | ||
96 | |||
97 | |||
98 | |||
99 | ####### Compile | ||
100 | |||
101 | clock.o: clock.cpp \ | ||
102 | clock.h \ | ||
103 | $(QPEDIR)/include/qpe/qpeapplication.h \ | ||
104 | $(QPEDIR)/include/qpe/qcopenvelope_qws.h \ | ||
105 | $(QPEDIR)/include/qpe/config.h \ | ||
106 | $(QPEDIR)/include/qpe/timestring.h | ||
107 | |||
108 | main.o: main.cpp \ | ||
109 | clock.h \ | ||
110 | $(QPEDIR)/include/qpe/qpeapplication.h | ||
111 | |||
112 | moc_clock.o: moc_clock.cpp \ | ||
113 | clock.h | ||
114 | |||
115 | moc_clock.cpp: clock.h | ||
116 | $(MOC) clock.h -o moc_clock.cpp | ||
117 | |||
118 | |||
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp new file mode 100644 index 0000000..ef93e11 --- a/dev/null +++ b/noncore/tools/clock/clock.cpp | |||
@@ -0,0 +1,319 @@ | |||
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 "clock.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpe/qcopenvelope_qws.h> | ||
25 | #include <qpe/config.h> | ||
26 | #include <qpe/timestring.h> | ||
27 | |||
28 | #include <qlcdnumber.h> | ||
29 | #include <qlabel.h> | ||
30 | #include <qlayout.h> | ||
31 | #include <qtimer.h> | ||
32 | #include <qpushbutton.h> | ||
33 | #include <qradiobutton.h> | ||
34 | #include <qbuttongroup.h> | ||
35 | #include <qpainter.h> | ||
36 | |||
37 | #include <math.h> | ||
38 | |||
39 | const double deg2rad = 0.017453292519943295769;// pi/180 | ||
40 | const int sw_prec = 2; | ||
41 | |||
42 | static void toggleScreenSaver( bool on ) | ||
43 | { | ||
44 | QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); | ||
45 | e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend ); | ||
46 | } | ||
47 | |||
48 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) | ||
49 | : QVBox( parent, name , f ) | ||
50 | { | ||
51 | setSpacing( 4 ); | ||
52 | setMargin( 1 ); | ||
53 | |||
54 | Config config( "qpe" ); | ||
55 | config.setGroup("Time"); | ||
56 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
57 | |||
58 | aclock = new AnalogClock( this ); | ||
59 | aclock->display( QTime::currentTime() ); | ||
60 | aclock->setLineWidth( 2 ); | ||
61 | |||
62 | QHBox *hb = new QHBox( this ); | ||
63 | hb->setMargin( 0 ); | ||
64 | QWidget *space = new QWidget( hb ); | ||
65 | lcd = new QLCDNumber( hb ); | ||
66 | lcd->setSegmentStyle( QLCDNumber::Flat ); | ||
67 | lcd->setFrameStyle( QFrame::NoFrame ); | ||
68 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | ||
69 | lcd->setFixedHeight( 23 ); | ||
70 | |||
71 | ampmLabel = new QLabel( "PM", hb ); | ||
72 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | ||
73 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); | ||
74 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); | ||
75 | space = new QWidget( hb ); | ||
76 | |||
77 | date = new QLabel( this ); | ||
78 | date->setAlignment( AlignHCenter | AlignVCenter ); | ||
79 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | ||
80 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | ||
81 | |||
82 | QWidget *controls = new QWidget( this ); | ||
83 | QGridLayout *gl = new QGridLayout( controls, 2, 2, 6, 4 ); | ||
84 | |||
85 | QButtonGroup *grp = new QButtonGroup( controls ); | ||
86 | grp->setRadioButtonExclusive( true ); | ||
87 | grp->hide(); | ||
88 | |||
89 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); | ||
90 | gl->addWidget( clockRB, 0, 0 ); | ||
91 | grp->insert( clockRB ); | ||
92 | |||
93 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); | ||
94 | gl->addWidget( swatchRB, 1, 0 ); | ||
95 | grp->insert( swatchRB ); | ||
96 | |||
97 | connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) ); | ||
98 | grp->setButton( 0 ); | ||
99 | |||
100 | set = new QPushButton ( controls ); | ||
101 | gl->addWidget( set, 0, 1 ); | ||
102 | set->setText( tr( "Start" ) ); | ||
103 | set->setEnabled( FALSE ); | ||
104 | grp->insert( set ); | ||
105 | |||
106 | reset = new QPushButton ( controls ); | ||
107 | gl->addWidget( reset, 1, 1 ); | ||
108 | reset->setText( tr( "Reset" ) ); | ||
109 | reset->setEnabled( FALSE ); | ||
110 | grp->insert( reset ); | ||
111 | |||
112 | connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); | ||
113 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); | ||
114 | |||
115 | t = new QTimer( this ); | ||
116 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); | ||
117 | t->start( 1000 ); | ||
118 | |||
119 | connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); | ||
120 | |||
121 | swatch_running = FALSE; | ||
122 | swatch_totalms = 0; | ||
123 | |||
124 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | ||
125 | |||
126 | QTimer::singleShot( 0, this, SLOT(updateClock()) ); | ||
127 | modeSelect(0); | ||
128 | } | ||
129 | |||
130 | Clock::~Clock() | ||
131 | { | ||
132 | toggleScreenSaver( true ); | ||
133 | } | ||
134 | |||
135 | void Clock::updateClock() | ||
136 | { | ||
137 | if ( clockRB->isChecked() ) { | ||
138 | QTime tm = QDateTime::currentDateTime().time(); | ||
139 | QString s; | ||
140 | if ( ampm ) { | ||
141 | int hour = tm.hour(); | ||
142 | if (hour == 0) | ||
143 | hour = 12; | ||
144 | if (hour > 12) | ||
145 | hour -= 12; | ||
146 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); | ||
147 | ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" ); | ||
148 | ampmLabel->show(); | ||
149 | } else { | ||
150 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); | ||
151 | ampmLabel->hide(); | ||
152 | } | ||
153 | lcd->display( s ); | ||
154 | lcd->repaint( FALSE ); | ||
155 | aclock->display( QTime::currentTime() ); | ||
156 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | ||
157 | } else { | ||
158 | QTime swatch_time; | ||
159 | QString lcdtext; | ||
160 | int totalms = swatch_totalms; | ||
161 | if ( swatch_running ) | ||
162 | totalms += swatch_start.elapsed(); | ||
163 | swatch_time = QTime(0,0,0).addMSecs(totalms); | ||
164 | QString d = swatch_running ? QString(" ") | ||
165 | : QString::number(totalms%1000+1000); | ||
166 | lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); | ||
167 | lcd->display( lcdtext ); | ||
168 | lcd->repaint( FALSE ); | ||
169 | aclock->display( swatch_time ); | ||
170 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | void Clock::changeClock( bool a ) | ||
175 | { | ||
176 | ampm = a; | ||
177 | updateClock(); | ||
178 | } | ||
179 | |||
180 | void Clock::clearClock( void ) | ||
181 | { | ||
182 | lcd->display( QTime( 0,0,0 ).toString() ); | ||
183 | aclock->display( QTime( 0,0,0 ) ); | ||
184 | } | ||
185 | |||
186 | void Clock::slotSet() | ||
187 | { | ||
188 | if ( t->isActive() ) { | ||
189 | swatch_totalms += swatch_start.elapsed(); | ||
190 | set->setText( tr( "Start" ) ); | ||
191 | t->stop(); | ||
192 | swatch_running = FALSE; | ||
193 | toggleScreenSaver( TRUE ); | ||
194 | updateClock(); | ||
195 | } else { | ||
196 | swatch_start.start(); | ||
197 | set->setText( tr( "Stop" ) ); | ||
198 | t->start( 1000 ); | ||
199 | swatch_running = TRUE; | ||
200 | // disable screensaver while stop watch is running | ||
201 | toggleScreenSaver( FALSE ); | ||
202 | } | ||
203 | } | ||
204 | |||
205 | void Clock::slotReset() | ||
206 | { | ||
207 | t->stop(); | ||
208 | swatch_start.start(); | ||
209 | swatch_totalms = 0; | ||
210 | |||
211 | if (swatch_running ) | ||
212 | t->start(1000); | ||
213 | |||
214 | updateClock(); | ||
215 | } | ||
216 | |||
217 | void Clock::modeSelect( int m ) | ||
218 | { | ||
219 | if ( m ) { | ||
220 | lcd->setNumDigits( 8+1+sw_prec ); | ||
221 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | ||
222 | set->setEnabled( TRUE ); | ||
223 | reset->setEnabled( TRUE ); | ||
224 | ampmLabel->hide(); | ||
225 | |||
226 | if ( !swatch_running ) | ||
227 | t->stop(); | ||
228 | } else { | ||
229 | lcd->setNumDigits( 5 ); | ||
230 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | ||
231 | set->setEnabled( FALSE ); | ||
232 | reset->setEnabled( FALSE ); | ||
233 | t->start(1000); | ||
234 | } | ||
235 | updateClock(); | ||
236 | } | ||
237 | |||
238 | QSizePolicy AnalogClock::sizePolicy() const | ||
239 | { | ||
240 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | ||
241 | } | ||
242 | |||
243 | void AnalogClock::drawContents( QPainter *p ) | ||
244 | { | ||
245 | QRect r = contentsRect(); | ||
246 | QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
247 | |||
248 | QPoint l1( r.x() + r.width() / 2, r.y() + 2 ); | ||
249 | QPoint l2( r.x() + r.width() / 2, r.y() + 8 ); | ||
250 | |||
251 | QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 ); | ||
252 | QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
253 | |||
254 | QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 ); | ||
255 | QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
256 | |||
257 | QPoint s1( r.x() + r.width() / 2, r.y() + 8 ); | ||
258 | QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 ); | ||
259 | |||
260 | QColor color( clear ? backgroundColor() : black ); | ||
261 | QTime time = clear ? prevTime : currTime; | ||
262 | |||
263 | if ( clear && prevTime.secsTo(currTime) > 1 ) { | ||
264 | p->eraseRect( rect() ); | ||
265 | return; | ||
266 | } | ||
267 | |||
268 | if ( !clear ) { | ||
269 | // draw ticks | ||
270 | p->setPen( QPen( color, 1 ) ); | ||
271 | for ( int i = 0; i < 12; i++ ) | ||
272 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); | ||
273 | } | ||
274 | |||
275 | if ( !clear || prevTime.minute() != currTime.minute() || | ||
276 | prevTime.hour() != currTime.hour() ) { | ||
277 | // draw hour pointer | ||
278 | h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); | ||
279 | h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 ); | ||
280 | p->setPen( QPen( color, 3 ) ); | ||
281 | p->drawLine( h1, h2 ); | ||
282 | } | ||
283 | |||
284 | if ( !clear || prevTime.minute() != currTime.minute() ) { | ||
285 | // draw minute pointer | ||
286 | m1 = rotate( center, m1, time.minute() * 6 ); | ||
287 | m2 = rotate( center, m2, time.minute() * 6 ); | ||
288 | p->setPen( QPen( color, 2 ) ); | ||
289 | p->drawLine( m1, m2 ); | ||
290 | } | ||
291 | |||
292 | // draw second pointer | ||
293 | s1 = rotate( center, s1, time.second() * 6 ); | ||
294 | s2 = rotate( center, s2, time.second() * 6 ); | ||
295 | p->setPen( QPen( color, 1 ) ); | ||
296 | p->drawLine( s1, s2 ); | ||
297 | |||
298 | if ( !clear ) | ||
299 | prevTime = currTime; | ||
300 | } | ||
301 | |||
302 | void AnalogClock::display( const QTime& t ) | ||
303 | { | ||
304 | currTime = t; | ||
305 | clear = true; | ||
306 | repaint( false ); | ||
307 | clear = false; | ||
308 | repaint( false ); | ||
309 | } | ||
310 | |||
311 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) | ||
312 | { | ||
313 | double angle = deg2rad * ( - a + 180 ); | ||
314 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - | ||
315 | ( p.y() - c.y() ) * sin( angle ); | ||
316 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + | ||
317 | ( p.x() - c.x() ) * sin( angle ); | ||
318 | return QPoint( nx, ny ); | ||
319 | } | ||
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h new file mode 100644 index 0000000..6dbebf7 --- a/dev/null +++ b/noncore/tools/clock/clock.h | |||
@@ -0,0 +1,87 @@ | |||
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 CLOCK_H | ||
21 | #define CLOCK_H | ||
22 | |||
23 | #include <qdatetime.h> | ||
24 | #include <qvbox.h> | ||
25 | |||
26 | class QLCDNumber; | ||
27 | class QLabel; | ||
28 | class QTimer; | ||
29 | class QRadioButton; | ||
30 | class QPushButton; | ||
31 | |||
32 | class AnalogClock : public QFrame | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | |||
36 | public: | ||
37 | AnalogClock( QWidget * parent = 0, const char * name = 0 ) | ||
38 | : QFrame( parent, name ), clear(false) {} | ||
39 | |||
40 | QSizePolicy sizePolicy() const; | ||
41 | |||
42 | void display( const QTime& time ); | ||
43 | |||
44 | protected: | ||
45 | void drawContents( QPainter *p ); | ||
46 | |||
47 | private: | ||
48 | QPoint rotate( QPoint center, QPoint p, int angle ); | ||
49 | |||
50 | QTime currTime; | ||
51 | QTime prevTime; | ||
52 | bool clear; | ||
53 | }; | ||
54 | |||
55 | class Clock : public QVBox | ||
56 | { | ||
57 | Q_OBJECT | ||
58 | |||
59 | public: | ||
60 | Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); | ||
61 | ~Clock(); | ||
62 | |||
63 | private slots: | ||
64 | void slotSet(); | ||
65 | void slotReset(); | ||
66 | void modeSelect(int); | ||
67 | void updateClock(); | ||
68 | void changeClock( bool ); | ||
69 | |||
70 | private: | ||
71 | void clearClock(); | ||
72 | |||
73 | QTimer *t; | ||
74 | QLCDNumber *lcd; | ||
75 | QLabel *date; | ||
76 | QLabel *ampmLabel; | ||
77 | QPushButton *set, *reset; | ||
78 | QRadioButton *clockRB, *swatchRB; | ||
79 | AnalogClock *aclock; | ||
80 | QTime swatch_start; | ||
81 | int swatch_totalms; | ||
82 | bool swatch_running; | ||
83 | bool ampm; | ||
84 | }; | ||
85 | |||
86 | #endif | ||
87 | |||
diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro new file mode 100644 index 0000000..97f4d2c --- a/dev/null +++ b/noncore/tools/clock/clock.pro | |||
@@ -0,0 +1,13 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | ||
3 | DESTDIR = $(QPEDIR)/bin | ||
4 | HEADERS = clock.h | ||
5 | SOURCES = clock.cpp \ | ||
6 | main.cpp | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH+= $(QPEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | INTERFACES= | ||
11 | TARGET = clock | ||
12 | |||
13 | TRANSLATIONS = ../i18n/de/clock.ts | ||
diff --git a/noncore/tools/clock/main.cpp b/noncore/tools/clock/main.cpp new file mode 100644 index 0000000..cbfb73b --- a/dev/null +++ b/noncore/tools/clock/main.cpp | |||
@@ -0,0 +1,34 @@ | |||
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 "clock.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | int main( int argc, char ** argv ) | ||
26 | { | ||
27 | QPEApplication a( argc, argv ); | ||
28 | |||
29 | Clock mw; | ||
30 | mw.setCaption( Clock::tr("Clock") ); | ||
31 | a.showMainWidget( &mw ); | ||
32 | |||
33 | return a.exec(); | ||
34 | } | ||
diff --git a/noncore/tools/clock/qpe-clock.control b/noncore/tools/clock/qpe-clock.control new file mode 100644 index 0000000..62f377f --- a/dev/null +++ b/noncore/tools/clock/qpe-clock.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: bin/clock apps/Applications/clock.desktop | ||
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: Clock and stop-watch | ||
9 | A simple clock and stop-watch for the Qtopia environment. | ||