summaryrefslogtreecommitdiff
path: root/noncore/tools/calc2
Unidiff
Diffstat (limited to 'noncore/tools/calc2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calc2/Makefile138
-rw-r--r--noncore/tools/calc2/binary/Makefile146
-rw-r--r--noncore/tools/calc2/binary/README1
-rw-r--r--noncore/tools/calc2/binary/binary.pro16
-rw-r--r--noncore/tools/calc2/binary/binary.ui177
-rw-r--r--noncore/tools/calc2/binary/binaryfactory.cpp51
-rw-r--r--noncore/tools/calc2/binary/binaryfactory.h46
-rw-r--r--noncore/tools/calc2/binary/binaryimpl.cpp110
-rw-r--r--noncore/tools/calc2/binary/binaryimpl.h50
-rw-r--r--noncore/tools/calc2/calc.cpp104
-rw-r--r--noncore/tools/calc2/calc.h69
-rw-r--r--noncore/tools/calc2/calc.pro11
-rw-r--r--noncore/tools/calc2/engine.cpp214
-rw-r--r--noncore/tools/calc2/engine.h111
-rw-r--r--noncore/tools/calc2/instruction.h69
-rw-r--r--noncore/tools/calc2/main.cpp34
-rw-r--r--noncore/tools/calc2/plugininterface.h45
-rw-r--r--noncore/tools/calc2/simple/README1
-rw-r--r--noncore/tools/calc2/simple/simple.pro14
-rw-r--r--noncore/tools/calc2/simple/simple.ui704
-rw-r--r--noncore/tools/calc2/simple/simplefactory.cpp51
-rw-r--r--noncore/tools/calc2/simple/simplefactory.h46
-rw-r--r--noncore/tools/calc2/simple/simpleimpl.cpp120
-rw-r--r--noncore/tools/calc2/simple/simpleimpl.h65
-rw-r--r--noncore/tools/calc2/stdinstructions.h125
25 files changed, 2518 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
46INTERFACE_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
70all: $(TARGET)
71
72$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
73 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
74
75moc: $(SRCMOC)
76
77tmake:
78 tmake calc.pro
79
80dist:
81 $(TAR) calc.tar calc.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
82 $(GZIP) calc.tar
83
84clean:
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
96calc.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
106main.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
116engine.o: engine.cpp \
117 engine.h \
118 instruction.h
119
120moc_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
129moc_engine.o: moc_engine.cpp \
130 engine.h \
131 instruction.h
132
133moc_calc.cpp: calc.h
134 $(MOC) calc.h -o moc_calc.cpp
135
136moc_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
49INTERFACE_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
73all: $(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
87staticlib: $(TARGETA)
88
89$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)
90 -rm -f $(TARGETA)
91 $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)
92
93moc: $(SRCMOC)
94
95tmake:
96 tmake binary.pro
97
98dist:
99 $(TAR) binary.tar binary.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
100 $(GZIP) binary.tar
101
102clean:
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
115binaryimpl.o: binaryimpl.cpp \
116 binaryimpl.h \
117 binary.h
118
119binaryfactory.o: binaryfactory.cpp \
120 binaryfactory.h \
121 binaryimpl.h \
122 binary.h
123
124binary.h: binary.ui
125 $(UIC) binary.ui -o $(INTERFACE_DECL_PATH)/binary.h
126
127binary.cpp: binary.ui
128 $(UIC) binary.ui -i binary.h -o binary.cpp
129
130binary.o: binary.cpp \
131 binary.h \
132 binary.ui
133
134moc_binaryimpl.o: moc_binaryimpl.cpp \
135 binaryimpl.h \
136 binary.h
137
138moc_binary.o: moc_binary.cpp \
139 binary.h
140
141moc_binaryimpl.cpp: binaryimpl.h
142 $(MOC) binaryimpl.h -o moc_binaryimpl.cpp
143
144moc_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 @@
1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt release
4
5# Input
6INTERFACES += binary.ui
7HEADERS = binaryimpl.h \
8 binaryfactory.h
9SOURCES = binaryimpl.cpp \
10 binaryfactory.cpp
11
12INCLUDEPATH += $(QPEDIR)/include \
13 $(QPEDIR)/calc2
14DEPENDPATH += $(QPEDIR)/include
15
16DESTDIR = $(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>&lt;-</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>-&gt;</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
27QWidget *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
34QRESULT 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
47Q_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
28class BinaryInterface : public CalcInterface
29{
30public:
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
41private:
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
24class iXOR : public Instruction {
25public:
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};
34class iAND : public Instruction {
35public:
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};
44class iNOT : public Instruction {
45public:
46 iNOT():Instruction(){};
47 ~iNOT(){};
48 Data eval(Data num) {
49 Data result;
50 result.i = ~ num.i;
51 return result;
52 };
53};
54class iOR : public Instruction {
55public:
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};
64class iLSH : public Instruction {
65public:
66 iLSH():Instruction(){};
67 ~iLSH(){};
68 Data eval(Data num) {
69 Data result;
70 result.i = num.i << 1;
71 return result;
72 };
73};
74class iRSH : public Instruction {
75public:
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
85void FormBinaryImpl::val0Clicked() {
86 engine->pushValue('0');
87}
88
89void FormBinaryImpl::val1Clicked() {
90 engine->pushValue('1');
91}
92
93void FormBinaryImpl::XORClicked() {
94 engine->pushInstruction(new iXOR());
95}
96void FormBinaryImpl::ANDClicked() {
97 engine->pushInstruction(new iAND());
98}
99void FormBinaryImpl::NOTClicked() {
100 engine->immediateInstruction(new iNOT());
101}
102void FormBinaryImpl::ORClicked() {
103 engine->pushInstruction(new iOR());
104}
105void FormBinaryImpl::LSHClicked() {
106 engine->immediateInstruction(new iLSH());
107}
108void 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
26class FormBinaryImpl : public FormBinary {
27Q_OBJECT
28public:
29 FormBinaryImpl(Engine *e,QWidget *p) : FormBinary (p,"Binary") {
30 engine = e;
31 engine->setRepresentation(rBin);
32 };
33 ~FormBinaryImpl(){};
34private:
35 Engine *engine;
36
37private 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
29calc::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);
37LCD->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
93calc::~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
39struct Plugin {
40#ifndef NO_PLUGINS
41 QLibrary *library;
42#endif
43 QWidget *pluginWidget;
44 CalcInterface *interface;
45 QString name;
46};
47
48class calc:public QWidget {
49
50Q_OBJECT
51public:
52 calc (QWidget * p = 0, const char *n = 0);
53 ~calc ();
54
55private:
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
65public 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 @@
1TEMPLATE = app
2CONFIG += qt release
3
4# Input
5HEADERS += calc.h plugininterface.h instruction.h engine.h stdinstructions.h
6SOURCES += calc.cpp main.cpp engine.cpp
7
8INCLUDEPATH += $(QPEDIR)/include
9DEPENDPATH += $(QPEDIR)/include
10LIBS += -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
26Data 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
56void 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
67void 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
77void 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
87void 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
121void 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
146void 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
163int 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
181class 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
194void Engine::openBrace() {
195 pushInstruction(new iOpenBrace(this));
196}
197
198void Engine::closeBrace() {
199 braces++;evalStack(num,TRUE);
200}
201
202// will need to show and hide display widgets
203void Engine::setRepresentation(Representation r) {
204 currentRep = r;
205 clearData(&num);
206 clearData(&mem);
207 state = sStart;
208}
209
210void 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
30enum State {
31 sStart,// start inputting a new number
32 sAppend,// continue inputting a number
33 sError
34};
35
36// State machine
37class Engine:public QWidget {
38
39Q_OBJECT
40public:
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
89private:
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
101signals:
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
24The first four types indicate an int,
25that is, Data.i, and are incompatible
26with the other two types.
27
28- Plugin is responsible for telling engine
29which Rep to use at any given time
30- Instructions from that plugin only
31have to handle that representation
32- Engine is responsible for error-checking
33according to its current rep and display */
34enum Representation {
35 rBin,
36 rOct,
37 rDec,
38 rHex,
39 rDouble,
40 rFraction
41};
42
43// An atom of data
44union Data {
45 int i;
46 double dbl;
47 struct Fraction {
48 int numerator, denominator;
49 } fraction;
50};
51
52// Instruction base class
53class Instruction {
54public:
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
23int 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
38class QWidget;
39class QObject;
40
41struct 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 @@
1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt release
4
5# Input
6INTERFACES += simple.ui
7HEADERS = simpleimpl.h simplefactory.h stdinstructions.h
8SOURCES = simpleimpl.cpp simplefactory.cpp
9
10INCLUDEPATH += $(QPEDIR)/include \
11 $(QPEDIR)/calc2
12DEPENDPATH += $(QPEDIR)/include
13
14DESTDIR = $(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
27QWidget *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
34QRESULT 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
47Q_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
28class SimpleInterface : public CalcInterface
29{
30public:
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
41private:
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
27void FormSimpleImpl::CEClicked() {
28 engine->hardReset();
29}
30
31void FormSimpleImpl::MCClicked() {
32 engine->memClear();
33}
34
35void FormSimpleImpl::MRClicked() {
36 engine->memRecall();
37}
38
39void FormSimpleImpl::MPlusClicked() {
40 engine->memSave();
41}
42
43void FormSimpleImpl::evalClicked() {
44 engine->eval();
45}
46
47void FormSimpleImpl::addClicked ()
48{
49 engine->pushInstruction (new iAdd ());
50}
51
52void FormSimpleImpl::subClicked ()
53{
54 engine->pushInstruction (new iSub ());
55}
56
57void FormSimpleImpl::mulClicked ()
58{
59 engine->pushInstruction (new iMul ());
60}
61
62void FormSimpleImpl::divClicked ()
63{
64 engine->pushInstruction (new iDiv ());
65}
66
67void FormSimpleImpl::decimalClicked ()
68{
69 engine->pushValue ('.');
70}
71
72void FormSimpleImpl::val1Clicked ()
73{
74 engine->pushValue ('1');
75}
76
77void FormSimpleImpl::val2Clicked ()
78{
79 engine->pushValue ('2');
80}
81
82void FormSimpleImpl::val3Clicked ()
83{
84 engine->pushValue ('3');
85}
86
87void FormSimpleImpl::val4Clicked ()
88{
89 engine->pushValue ('4');
90}
91
92void FormSimpleImpl::val5Clicked ()
93{
94 engine->pushValue ('5');
95}
96
97void FormSimpleImpl::val6Clicked ()
98{
99 engine->pushValue ('6');
100}
101
102void FormSimpleImpl::val7Clicked ()
103{
104 engine->pushValue ('7');
105}
106
107void FormSimpleImpl::val8Clicked ()
108{
109 engine->pushValue ('8');
110}
111
112void FormSimpleImpl::val9Clicked ()
113{
114 engine->pushValue ('9');
115}
116
117void 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
31class FormSimpleImpl:public FormSimple {
32Q_OBJECT
33public:
34 FormSimpleImpl (Engine *e, QWidget * parent = 0, const char *name = 0)
35 :FormSimple (parent, name) {engine = e;engine->setRepresentation(rDouble);};
36
37 ~FormSimpleImpl () { };
38
39private:
40 Engine *engine;
41
42private 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
29class iAdd:public Instruction {
30public:
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};
45class iSub:public Instruction {
46public:
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};
61class iMul:public Instruction {
62public:
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};
77class iDiv:public Instruction {
78public:
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
95class iSin:public Instruction {
96public:
97 iSin ():Instruction () { };
98 ~iSin () { };
99 Data eval (Data num) {
100 Data result;
101 result.dbl = qSin(num.dbl);
102 return result;
103 };
104};
105class iCos:public Instruction {
106public:
107 iCos ():Instruction () { };
108 ~iCos () { };
109 Data eval (Data num) {
110 Data result;
111 result.dbl = qCos(num.dbl);
112 return result;
113 };
114};
115class iTan:public Instruction {
116public:
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