summaryrefslogtreecommitdiff
path: root/noncore/tools/calc2
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (side-by-side diff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /noncore/tools/calc2
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
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 @@
+#############################################################################
+# Makefile for building calc
+# Generated by tmake at 12:06, 2001/11/26
+# Project: calc
+# Template: app
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+CFLAGS = -pipe -Wall -W -O2 -DNO_DEBUG
+CXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG
+INCPATH = -I$(QPEDIR)/include -I$(QTDIR)/include
+LINK = gcc
+LFLAGS =
+LIBS = $(SUBLIBS) -L$(QTDIR)/lib -lqpe -Wl,-export-dynamic -lqte
+MOC = $(QTDIR)/bin/moc
+UIC = $(QTDIR)/bin/uic
+
+TAR = tar -cf
+GZIP = gzip -9f
+
+####### Files
+
+HEADERS = calc.h \
+ plugininterface.h \
+ instruction.h \
+ engine.h \
+ stdinstructions.h
+SOURCES = calc.cpp \
+ main.cpp \
+ engine.cpp
+OBJECTS = calc.o \
+ main.o \
+ engine.o
+INTERFACES =
+UICDECLS =
+UICIMPLS =
+SRCMOC = moc_calc.cpp \
+ moc_engine.cpp
+OBJMOC = moc_calc.o \
+ moc_engine.o
+DIST =
+TARGET = calc
+INTERFACE_DECL_PATH = .
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+
+all: $(TARGET)
+
+$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
+ $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
+
+moc: $(SRCMOC)
+
+tmake:
+ tmake calc.pro
+
+dist:
+ $(TAR) calc.tar calc.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
+ $(GZIP) calc.tar
+
+clean:
+ -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
+ -rm -f *~ core
+
+####### Sub-libraries
+
+
+###### Combined headers
+
+
+####### Compile
+
+calc.o: calc.cpp \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qpeapplication.h \
+ calc.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qlibrary.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qcom.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/quuid.h \
+ engine.h \
+ instruction.h \
+ plugininterface.h
+
+main.o: main.cpp \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qpeapplication.h \
+ calc.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qlibrary.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qcom.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/quuid.h \
+ engine.h \
+ instruction.h \
+ plugininterface.h
+
+engine.o: engine.cpp \
+ engine.h \
+ instruction.h
+
+moc_calc.o: moc_calc.cpp \
+ calc.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qlibrary.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/qcom.h \
+ /home/luke/builds/2.3.2-emb/qpe/include/qpe/quuid.h \
+ engine.h \
+ instruction.h \
+ plugininterface.h
+
+moc_engine.o: moc_engine.cpp \
+ engine.h \
+ instruction.h
+
+moc_calc.cpp: calc.h
+ $(MOC) calc.h -o moc_calc.cpp
+
+moc_engine.cpp: engine.h
+ $(MOC) engine.h -o moc_engine.cpp
+
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 @@
+#############################################################################
+# Makefile for building libbinary.so.1.0.0
+# Generated by tmake at 12:03, 2001/11/22
+# Project: binary
+# Template: lib
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+CFLAGS = -pipe -Wall -W -O2 -fPIC -DNO_DEBUG
+CXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fPIC -DNO_DEBUG
+INCPATH = -I$(QPEDIR)/include -I$(QPEDIR)/calc2 -I$(QTDIR)/include
+LINK = gcc
+LFLAGS = -shared -Wl,-soname,libbinary.so.1
+LIBS = $(SUBLIBS) -L$(QTDIR)/lib -lqte
+AR = ar cqs
+RANLIB =
+MOC = $(QTDIR)/bin/moc
+UIC = $(QTDIR)/bin/uic
+
+TAR = tar -cf
+GZIP = gzip -9f
+
+####### Files
+
+HEADERS = binaryimpl.h \
+ binaryfactory.h
+SOURCES = binaryimpl.cpp \
+ binaryfactory.cpp
+OBJECTS = binaryimpl.o \
+ binaryfactory.o \
+ binary.o
+INTERFACES = binary.ui
+UICDECLS = binary.h
+UICIMPLS = binary.cpp
+SRCMOC = moc_binaryimpl.cpp \
+ moc_binary.cpp
+OBJMOC = moc_binaryimpl.o \
+ moc_binary.o
+DIST =
+TARGET = libbinary.so.1.0.0
+TARGETA = $(QPEDIR)/plugins/calculator/libbinary.a
+TARGETD = libbinary.so.1.0.0
+TARGET0 = libbinary.so
+TARGET1 = libbinary.so.1
+TARGET2 = libbinary.so.1.0
+INTERFACE_DECL_PATH = .
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+
+all: $(QPEDIR)/plugins/calculator/libbinary.so.1.0.0
+
+$(QPEDIR)/plugins/calculator/libbinary.so.1.0.0: $(OBJECTS) $(OBJMOC) $(SUBLIBS)
+ -rm -f $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
+ $(LINK) $(LFLAGS) -o $(TARGETD) $(OBJECTS) $(OBJMOC) $(LIBS)
+ -ln -s $(TARGET) $(TARGET0)
+ -ln -s $(TARGET) $(TARGET1)
+ -ln -s $(TARGET) $(TARGET2)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET0)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET1)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET2)
+ -mv $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(QPEDIR)/plugins/calculator/
+
+staticlib: $(TARGETA)
+
+$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)
+ -rm -f $(TARGETA)
+ $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)
+
+moc: $(SRCMOC)
+
+tmake:
+ tmake binary.pro
+
+dist:
+ $(TAR) binary.tar binary.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
+ $(GZIP) binary.tar
+
+clean:
+ -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
+ -rm -f $(TARGET0) $(TARGET1) $(TARGET2) $(TARGETA)
+ -rm -f *~ core
+
+####### Sub-libraries
+
+
+###### Combined headers
+
+
+####### Compile
+
+binaryimpl.o: binaryimpl.cpp \
+ binaryimpl.h \
+ binary.h
+
+binaryfactory.o: binaryfactory.cpp \
+ binaryfactory.h \
+ binaryimpl.h \
+ binary.h
+
+binary.h: binary.ui
+ $(UIC) binary.ui -o $(INTERFACE_DECL_PATH)/binary.h
+
+binary.cpp: binary.ui
+ $(UIC) binary.ui -i binary.h -o binary.cpp
+
+binary.o: binary.cpp \
+ binary.h \
+ binary.ui
+
+moc_binaryimpl.o: moc_binaryimpl.cpp \
+ binaryimpl.h \
+ binary.h
+
+moc_binary.o: moc_binary.cpp \
+ binary.h
+
+moc_binaryimpl.cpp: binaryimpl.h
+ $(MOC) binaryimpl.h -o moc_binaryimpl.cpp
+
+moc_binary.cpp: binary.h
+ $(MOC) binary.h -o moc_binary.cpp
+
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 @@
+TEMPLATE = lib
+CONFIG -= moc
+CONFIG += qt release
+
+# Input
+INTERFACES += binary.ui
+HEADERS = binaryimpl.h \
+ binaryfactory.h
+SOURCES = binaryimpl.cpp \
+ binaryfactory.cpp
+
+INCLUDEPATH += $(QPEDIR)/include \
+ $(QPEDIR)/calc2
+DEPENDPATH += $(QPEDIR)/include
+
+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 @@
+<!DOCTYPE UI><UI>
+<class>FormBinary</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>FormBinary</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>332</width>
+ <height>114</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Binary</string>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget row="1" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB0</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>0</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB1</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>1</string>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBAnd</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>AND</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBOr</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>OR</string>
+ </property>
+ </widget>
+ <widget row="0" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBNot</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>NOT</string>
+ </property>
+ </widget>
+ <widget row="1" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBSHL</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;-</string>
+ </property>
+ </widget>
+ <widget row="0" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBXor</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>XOR</string>
+ </property>
+ </widget>
+ <widget row="1" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBSHR</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>-&gt;</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+</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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "binaryfactory.h"
+#include "binaryimpl.h"
+#include <engine.h>
+
+QWidget *BinaryInterface::getPlugin ( Engine *e, QWidget *parent ) {
+ if ( !input )
+ input = new FormBinaryImpl ( e, parent );
+ return input;
+}
+
+#ifndef QT_NO_COMPONENT
+QRESULT BinaryInterface::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_Calc )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( BinaryInterface )
+}
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef BINARYIMPL_H
+#define BINARYIMPL_H
+
+#include "binaryimpl.h"
+#include <plugininterface.h>
+#include <engine.h>
+
+class BinaryInterface : public CalcInterface
+{
+public:
+ BinaryInterface(){input = 0;};
+ virtual ~BinaryInterface(){};
+
+#ifndef QT_NO_COMPONENT
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+#endif
+
+ QWidget *getPlugin( Engine *, QWidget *parent );
+
+private:
+ FormBinaryImpl *input;
+ ulong ref;
+};
+
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "binaryimpl.h"
+#include <instruction.h>
+
+class iXOR : public Instruction {
+public:
+ iXOR():Instruction(){};
+ ~iXOR(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i ^ acc.i;
+ return result;
+ };
+};
+class iAND : public Instruction {
+public:
+ iAND():Instruction(){};
+ ~iAND(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i & acc.i;
+ return result;
+ };
+};
+class iNOT : public Instruction {
+public:
+ iNOT():Instruction(){};
+ ~iNOT(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = ~ num.i;
+ return result;
+ };
+};
+class iOR : public Instruction {
+public:
+ iOR():Instruction(){};
+ ~iOR(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i | acc.i;
+ return result;
+ };
+};
+class iLSH : public Instruction {
+public:
+ iLSH():Instruction(){};
+ ~iLSH(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i << 1;
+ return result;
+ };
+};
+class iRSH : public Instruction {
+public:
+ iRSH():Instruction(){};
+ ~iRSH(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i >> 1;
+ return result;
+ };
+};
+
+void FormBinaryImpl::val0Clicked() {
+ engine->pushValue('0');
+}
+
+void FormBinaryImpl::val1Clicked() {
+ engine->pushValue('1');
+}
+
+void FormBinaryImpl::XORClicked() {
+ engine->pushInstruction(new iXOR());
+}
+void FormBinaryImpl::ANDClicked() {
+ engine->pushInstruction(new iAND());
+}
+void FormBinaryImpl::NOTClicked() {
+ engine->immediateInstruction(new iNOT());
+}
+void FormBinaryImpl::ORClicked() {
+ engine->pushInstruction(new iOR());
+}
+void FormBinaryImpl::LSHClicked() {
+ engine->immediateInstruction(new iLSH());
+}
+void FormBinaryImpl::RSHClicked() {
+ engine->immediateInstruction(new iRSH());
+}
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef FORMBINARYINPUTIMPL
+#define FORMBINARYINPUTIMPL
+
+#include "binary.h"
+#include <engine.h>
+
+class FormBinaryImpl : public FormBinary {
+Q_OBJECT
+public:
+ FormBinaryImpl(Engine *e,QWidget *p) : FormBinary (p,"Binary") {
+ engine = e;
+ engine->setRepresentation(rBin);
+ };
+ ~FormBinaryImpl(){};
+private:
+ Engine *engine;
+
+private slots:
+ void val0Clicked();
+ void val1Clicked();
+
+ void XORClicked();
+ void ANDClicked();
+ void NOTClicked();
+ void ORClicked();
+
+ void LSHClicked();
+ void RSHClicked();
+};
+
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qvaluelist.h>
+#include <qpe/qpeapplication.h>
+#include <qdir.h>
+#include <qwidgetstack.h>
+
+#include "calc.h"
+#include "plugininterface.h"
+
+calc::calc (QWidget * p = 0, const char *n = 0):QWidget (p, n)
+{
+ setCaption (tr ("Calculator"));
+
+// widgets
+ LCD = new QLCDNumber (this);
+ LCD->setMaximumSize (QSize (240, 30));
+ LCD->setNumDigits(12);
+LCD->setSegmentStyle(QLCDNumber::Filled);
+ pluginWidgetStack = new QWidgetStack (this);
+
+// layout widgets
+ calculatorLayout = new QVBoxLayout (this);
+ calculatorLayout->addWidget (LCD);
+ calculatorLayout->addWidget (pluginWidgetStack);
+
+// no formatting of display for now
+ connect (&engine, SIGNAL(display (double)), LCD, SLOT(display (double)));
+ connect (&engine, SIGNAL(display (const QString &)), LCD, SLOT(display (const QString &)));
+ connect (&engine, SIGNAL(setBinMode()), LCD, SLOT(setBinMode()));
+ connect (&engine, SIGNAL(setOctMode()), LCD, SLOT(setOctMode()));
+ connect (&engine, SIGNAL(setDecMode()), LCD, SLOT(setDecMode()));
+ connect (&engine, SIGNAL(setHexMode()), LCD, SLOT(setHexMode()));
+
+#ifndef NO_PLUGINS
+// load plugins
+ QValueList < Plugin >::Iterator mit;
+ for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) {
+ (*mit).interface->release ();
+ (*mit).library->unload ();
+ delete (*mit).library;
+ }
+ pluginList.clear ();
+
+ QString path = QPEApplication::qpeDir() + "/plugins/calculator";
+ QDir dir (path, "lib*.so");
+ QStringList list = dir.entryList ();
+
+ QStringList::Iterator it;
+ for (it = list.begin (); it != list.end (); ++it) {
+ CalcInterface *iface = 0;
+ QLibrary *lib = new QLibrary (path + "/" + *it);
+
+ Plugin plugin;
+ plugin.pluginWidget = 0;
+
+ if (lib->queryInterface (IID_Calc, (QUnknownInterface **) & iface) ==
+ QS_OK) {
+ plugin.library = lib;
+ plugin.interface = iface;
+ plugin.pluginWidget = plugin.interface->getPlugin(&engine,pluginWidgetStack);
+ if (plugin.pluginWidget)
+ pluginWidgetStack->addWidget (plugin.pluginWidget, pluginList.count());
+ pluginList.append (plugin);
+ } else {
+ delete lib;
+ }
+ }
+ setMode (1);
+#else
+// load simple interface
+#endif
+}
+
+calc::~calc ()
+{
+#ifndef NO_PLUGINS
+ QValueList < Plugin >::Iterator mit;
+ for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) {
+ (*mit).interface->release ();
+ (*mit).library->unload ();
+ delete (*mit).library;
+ }
+#endif
+}
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef CALC_H
+#define CALC_H
+
+#ifdef QT_NO_COMPONENT
+#define NO_PLUGINS
+#endif
+
+#include <qlayout.h>
+#include <qwidgetstack.h>
+
+#ifndef NO_PLUGINS
+#include <qvaluelist.h>
+#include <qpe/qlibrary.h>
+#endif
+
+#include "engine.h"
+#include "plugininterface.h"
+
+struct Plugin {
+#ifndef NO_PLUGINS
+ QLibrary *library;
+#endif
+ QWidget *pluginWidget;
+ CalcInterface *interface;
+ QString name;
+};
+
+class calc:public QWidget {
+
+Q_OBJECT
+public:
+ calc (QWidget * p = 0, const char *n = 0);
+ ~calc ();
+
+private:
+#ifndef NO_PLUGINS
+ void loadPlugins ();
+ QValueList < Plugin > pluginList;
+#endif
+ QVBoxLayout *calculatorLayout;
+ QWidgetStack *pluginWidgetStack;
+ QLCDNumber *LCD;
+ Engine engine;
+
+public slots:
+ void setMode(int m){pluginWidgetStack->raiseWidget(m);};
+};
+
+#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 @@
+TEMPLATE = app
+CONFIG += qt release
+
+# Input
+HEADERS += calc.h plugininterface.h instruction.h engine.h stdinstructions.h
+SOURCES += calc.cpp main.cpp engine.cpp
+
+INCLUDEPATH += $(QPEDIR)/include
+DEPENDPATH += $(QPEDIR)/include
+LIBS += -lqpe -Wl,-export-dynamic
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "engine.h"
+#include <qstring.h>
+#include <math.h>
+#include <qlcdnumber.h>
+
+Data Engine::evalStack (Data num, bool inbrace = FALSE)
+{
+ if (state != sError) {
+ Instruction *i;
+
+// Pop the next op from the stack
+ while (!stack.isEmpty () && (braces || !inbrace)) {
+ i = stack.pop ();
+
+// Check this ops prec vs next ops prec
+ if (!stack.isEmpty ())
+ if (i->precedence <= stack.top()->precedence)
+ i->acc = evalStack (i->acc, inbrace);
+
+// Evaluate this instruction
+ num = i->eval (num);
+
+// Error-check ( change this to work for all types )
+ if (isnan (num.dbl) || isinf (num.dbl)) {
+ qDebug ("bad result from operation");
+ state = sError;
+ clearData(&num);
+ return num;
+ }
+ }
+ }
+ return num;
+}
+
+// Plugins call this to request the stack be evaluated
+void Engine::eval ()
+{
+ num = evalStack (num);
+ if (state != sError) {
+ displayData(num);
+ state = sStart;
+ }
+// if the user didnt close all their braces, its no big deal
+ braces = 0;
+}
+
+void Engine::immediateInstruction (Instruction * i)
+{
+ if (state != sError) {
+ i->setRep(currentRep);
+ num = i->eval (num);
+ displayData(num);
+ state = sStart;
+ }
+}
+
+void Engine::pushInstruction (Instruction * i)
+{
+ if (state != sError) {
+ i->setRep(currentRep);
+ i->acc = num;
+ stack.push (i);
+ state = sStart;
+ }
+}
+
+void Engine::pushValue (char v)
+{
+ if (state == sAppend) {
+ bool ok = FALSE;
+ switch (currentRep) {
+ case rDouble:
+ displayString.append(v);
+ num.dbl=displayString.toDouble(&ok);
+ break;
+ case rFraction:
+ break;
+ default:
+ displayString.append(v);
+ num.i=displayString.toInt(&ok, calcBase());
+ };
+ if (!ok) {
+ state = sError;
+ qDebug("pushValue() - num->string conversion");
+ } else {
+ const QString constString = displayString;
+ emit(display(constString));
+ };
+
+ } else if (state == sStart) {
+ softReset();
+ displayString.truncate(0);
+ state = sAppend;
+ pushValue (v);
+ } else if (state == sError) {
+ qDebug ("in error state");
+ return;
+ }
+}
+
+void Engine::del ()
+{
+ bool ok;
+ switch (currentRep) {
+ case rDouble:
+ displayString.truncate(displayString.length());
+ num.dbl=displayString.toDouble(&ok);
+ break;
+ case rFraction:
+ qDebug("not available");
+ break;
+ default:
+ displayString.truncate(displayString.length());
+ num.i = displayString.toInt(&ok, calcBase());
+ };
+
+ if (!ok) {
+ state = sError;
+ qDebug("del() - num->string conversion");
+ } else {
+ const QString constString = displayString;
+ emit(display(constString));
+ };
+}
+
+void Engine::displayData(Data d) {
+ switch (currentRep) {
+ case rDouble:
+ displayString.setNum(d.dbl);
+ break;
+ case rFraction:
+ qDebug("fractional display not yet impl");
+ break;
+ default:
+ displayString.setNum(d.i, calcBase());
+ break;
+ };
+ const QString constString= displayString;
+ emit(display(constString));
+}
+
+// Returns the base when Rep is an integer type
+int Engine::calcBase () {
+ switch (currentRep) {
+ case rBin:
+ return 2;
+ case rOct:
+ return 8;
+ case rDec:
+ return 10;
+ case rHex:
+ return 16;
+ default:
+ state = sError;
+ qDebug("Error - attempt to calc base for non-integer");
+ return 10;
+ };
+}
+
+// Special instruction for internal use only
+class iOpenBrace:public Instruction {
+ public:
+ iOpenBrace (Engine *e):Instruction (100) {engine = e;};
+ ~iOpenBrace () {};
+
+ Data eval (Data num) {
+ engine->decBraces();
+ return num;
+ };
+ private:
+ Engine *engine;
+};
+
+void Engine::openBrace() {
+ pushInstruction(new iOpenBrace(this));
+}
+
+void Engine::closeBrace() {
+ braces++;evalStack(num,TRUE);
+}
+
+// will need to show and hide display widgets
+void Engine::setRepresentation(Representation r) {
+ currentRep = r;
+ clearData(&num);
+ clearData(&mem);
+ state = sStart;
+}
+
+void Engine::clearData(Data *d) {
+ d->i = d->fraction.numerator = d->fraction.denominator = 0;
+ d->dbl = 0;
+}
+
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef ENGINE_H
+#define ENGINE_H
+
+#include <qwidget.h>
+#include <qstack.h> // Instruction stack
+#include <qstring.h> // Display
+#include "instruction.h"
+
+// Possible states
+enum State {
+ sStart, // start inputting a new number
+ sAppend, // continue inputting a number
+ sError
+};
+
+// State machine
+class Engine:public QWidget {
+
+Q_OBJECT
+public:
+ Engine (QWidget * parent = 0, const char *name = 0):QWidget (parent, name) {
+ hardReset();
+ setRepresentation(rDec);
+ };
+
+ ~Engine () { };
+
+ void immediateInstruction (Instruction *);
+ void pushInstruction (Instruction *);
+ void eval ();
+
+ void pushValue (char);
+ void del ();
+
+ void openBrace ();
+ void closeBrace ();
+
+ void softReset () { // clears the number being inputted
+ decimalPlaces = -1;
+ clearData(&num);
+ displayData(num);
+ state = sStart;
+ };
+ void hardReset () { // a "real" reset of the stack
+ stack.clear ();
+ memClear();
+ braces = 0;
+ softReset ();
+ };
+
+ void memSave () {
+ mem = num;
+ };
+ void memRecall () {
+ num = mem;
+ state = sStart;
+ displayData(num);
+ };
+ void memClear () {
+ clearData(&mem);
+ };
+
+ // rFraction will require a special display enabled here
+ void setRepresentation(Representation);
+
+ // you dont want to call this
+ void decBraces(void){ braces--; };
+
+private:
+ void displayData(Data d);
+ void clearData(Data *d);
+ int calcBase();
+ Data evalStack (Data, bool);
+ Data num,mem;
+ State state;
+ QStack < Instruction > stack;
+ Representation currentRep;
+ int braces, decimalPlaces; // count of finishing 0's in num
+ QString displayString; // saves instatiating it over and over
+
+signals:
+ void display(const QString &);
+ void display(double); // could get rid of this and
+ // use a QLabel instead.
+ void setHexMode();
+ void setBinMode();
+ void setDecMode();
+ void setOctMode();
+};
+
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef INSTRUCTION_H
+#define INSTRUCTION_H
+
+/* Internal representation of data
+The first four types indicate an int,
+that is, Data.i, and are incompatible
+with the other two types.
+
+- Plugin is responsible for telling engine
+which Rep to use at any given time
+- Instructions from that plugin only
+have to handle that representation
+- Engine is responsible for error-checking
+according to its current rep and display */
+enum Representation {
+ rBin,
+ rOct,
+ rDec,
+ rHex,
+ rDouble,
+ rFraction
+};
+
+// An atom of data
+union Data {
+ int i;
+ double dbl;
+ struct Fraction {
+ int numerator, denominator;
+ } fraction;
+};
+
+// Instruction base class
+class Instruction {
+public:
+ Instruction (int p = 0) {
+ precedence = p;
+ };
+
+ virtual ~ Instruction () {};
+
+ virtual Data eval(Data) = 0;
+ void setRep(Representation r) { rep = r; };
+
+ Representation rep;
+ Data acc;
+ int precedence;
+};
+
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#include <qpe/qpeapplication.h>
+#include "calc.h"
+
+int main (int argc, char **argv)
+{
+ QPEApplication a (argc, argv);
+
+ calc mw;
+
+ QPEApplication::setInputMethodHint (&mw, QPEApplication::AlwaysOff);
+ mw.setCaption (calc::tr ("Calculator"));
+ a.showMainWidget (&mw);
+
+ return a.exec ();
+}
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef CALCINTERFACE_H
+#define CALCINTERFACE_H
+
+#include <qnamespace.h>
+#include <qstring.h>
+#include <qlcdnumber.h>
+#include <qpe/qcom.h>
+
+#include "engine.h"
+
+#ifndef QT_NO_COMPONENT
+// {3CE88B66-B3FD-4580-9D04-77338A31A667}
+#ifndef IID_Calc
+#define IID_Calc QUuid( 0x3ce88b66, 0xb3fd, 0x4580, 0x9d, 0x04, 0x77, 0x33, 0x8a, 0x31, 0xa6, 0x67)
+#endif
+#endif
+
+class QWidget;
+class QObject;
+
+struct CalcInterface:public QUnknownInterface {
+ virtual QWidget *getPlugin (Engine *e, QWidget * parent) = 0;
+};
+
+#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 @@
+TEMPLATE = lib
+CONFIG -= moc
+CONFIG += qt release
+
+# Input
+INTERFACES += simple.ui
+HEADERS = simpleimpl.h simplefactory.h stdinstructions.h
+SOURCES = simpleimpl.cpp simplefactory.cpp
+
+INCLUDEPATH += $(QPEDIR)/include \
+ $(QPEDIR)/calc2
+DEPENDPATH += $(QPEDIR)/include
+
+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 @@
+<!DOCTYPE UI><UI>
+<class>FormSimple</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>FormSimple</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>73</x>
+ <y>0</y>
+ <width>240</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>240</width>
+ <height>320</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>baseSize</name>
+ <size>
+ <width>240</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Simple</string>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget row="4" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBEval</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>160</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>=</string>
+ </property>
+ </widget>
+ <widget row="2" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB5</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>5</string>
+ </property>
+ </widget>
+ <widget row="4" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBDecimal</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>.</string>
+ </property>
+ </widget>
+ <widget row="3" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB3</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>3</string>
+ </property>
+ </widget>
+ <widget row="3" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB2</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>2</string>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB4</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>4</string>
+ </property>
+ </widget>
+ <widget row="2" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB6</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>6</string>
+ </property>
+ </widget>
+ <widget row="3" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBMul</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>*</string>
+ </property>
+ </widget>
+ <widget row="2" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBSub</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>-</string>
+ </property>
+ </widget>
+ <widget row="1" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBAdd</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>+</string>
+ </property>
+ </widget>
+ <widget row="1" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB9</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>9</string>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB7</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>7</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB1</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>1</string>
+ </property>
+ </widget>
+ <widget row="4" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB0</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>160</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>0</string>
+ </property>
+ </widget>
+ <widget row="4" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBDiv</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>/</string>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB8</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>8</string>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBMPlus</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>M+</string>
+ </property>
+ </widget>
+ <widget row="0" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBCE</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>CE</string>
+ </property>
+ </widget>
+ <widget row="0" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBMC</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>MC</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBMR</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>4</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>MR</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>PB0</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val0Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB1</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val1Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB2</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val2Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB3</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val3Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB4</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val4Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB5</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val5Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB6</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val6Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB7</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val7Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB8</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val8Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PB9</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>val9Clicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBSub</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>subClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBMul</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>mulClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBDiv</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>divClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBDecimal</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>decimalClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBEval</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>evalClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBMC</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>MCClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBMPlus</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>MPlusClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBMR</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>MRClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBAdd</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>addClicked()</slot>
+ </connection>
+ <connection>
+ <sender>PBCE</sender>
+ <signal>clicked()</signal>
+ <receiver>FormSimple</receiver>
+ <slot>CEClicked()</slot>
+ </connection>
+ <slot access="public">CEClicked()</slot>
+ <slot access="public">MCClicked()</slot>
+ <slot access="public">MPlusClicked()</slot>
+ <slot access="public">MRClicked()</slot>
+ <slot access="public">addClicked()</slot>
+ <slot access="public">decimalClicked()</slot>
+ <slot access="public">divClicked()</slot>
+ <slot access="public">evalClicked()</slot>
+ <slot access="public">mulClicked()</slot>
+ <slot access="public">subClicked()</slot>
+ <slot access="public">val0Clicked()</slot>
+ <slot access="public">val1Clicked()</slot>
+ <slot access="public">val2Clicked()</slot>
+ <slot access="public">val3Clicked()</slot>
+ <slot access="public">val4Clicked()</slot>
+ <slot access="public">val5Clicked()</slot>
+ <slot access="public">val6Clicked()</slot>
+ <slot access="public">val7Clicked()</slot>
+ <slot access="public">val8Clicked()</slot>
+ <slot access="public">val9Clicked()</slot>
+</connections>
+</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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "simplefactory.h"
+#include "simpleimpl.h"
+#include <engine.h>
+
+QWidget *SimpleInterface::getPlugin ( Engine *e, QWidget *parent ) {
+ if ( !input )
+ input = new FormSimpleImpl ( e, parent );
+ return input;
+}
+
+#ifndef QT_NO_COMPONENT
+QRESULT SimpleInterface::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_Calc )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( SimpleInterface )
+}
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef BINARYIMPL_H
+#define BINARYIMPL_H
+
+#include "simpleimpl.h"
+#include <plugininterface.h>
+#include <engine.h>
+
+class SimpleInterface : public CalcInterface
+{
+public:
+ SimpleInterface(){input = 0;};
+ virtual ~SimpleInterface(){};
+
+#ifndef QT_NO_COMPONENT
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+#endif
+
+ QWidget *getPlugin( Engine *, QWidget *parent );
+
+private:
+ FormSimpleImpl *input;
+ ulong ref;
+};
+
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qpushbutton.h>
+#include <qlcdnumber.h>
+
+#include "simpleimpl.h"
+#include <stdinstructions.h>
+
+void FormSimpleImpl::CEClicked() {
+ engine->hardReset();
+}
+
+void FormSimpleImpl::MCClicked() {
+ engine->memClear();
+}
+
+void FormSimpleImpl::MRClicked() {
+ engine->memRecall();
+}
+
+void FormSimpleImpl::MPlusClicked() {
+ engine->memSave();
+}
+
+void FormSimpleImpl::evalClicked() {
+ engine->eval();
+}
+
+void FormSimpleImpl::addClicked ()
+{
+ engine->pushInstruction (new iAdd ());
+}
+
+void FormSimpleImpl::subClicked ()
+{
+ engine->pushInstruction (new iSub ());
+}
+
+void FormSimpleImpl::mulClicked ()
+{
+ engine->pushInstruction (new iMul ());
+}
+
+void FormSimpleImpl::divClicked ()
+{
+ engine->pushInstruction (new iDiv ());
+}
+
+void FormSimpleImpl::decimalClicked ()
+{
+ engine->pushValue ('.');
+}
+
+void FormSimpleImpl::val1Clicked ()
+{
+ engine->pushValue ('1');
+}
+
+void FormSimpleImpl::val2Clicked ()
+{
+ engine->pushValue ('2');
+}
+
+void FormSimpleImpl::val3Clicked ()
+{
+ engine->pushValue ('3');
+}
+
+void FormSimpleImpl::val4Clicked ()
+{
+ engine->pushValue ('4');
+}
+
+void FormSimpleImpl::val5Clicked ()
+{
+ engine->pushValue ('5');
+}
+
+void FormSimpleImpl::val6Clicked ()
+{
+ engine->pushValue ('6');
+}
+
+void FormSimpleImpl::val7Clicked ()
+{
+ engine->pushValue ('7');
+}
+
+void FormSimpleImpl::val8Clicked ()
+{
+ engine->pushValue ('8');
+}
+
+void FormSimpleImpl::val9Clicked ()
+{
+ engine->pushValue ('9');
+}
+
+void FormSimpleImpl::val0Clicked ()
+{
+ engine->pushValue ('0');
+}
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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef STANDARDIMPL_H
+#define STANDARDIMPL_H
+
+#include <qpe/qmath.h>
+#include <qlcdnumber.h>
+
+#include "simple.h"
+#include "engine.h"
+#include "instruction.h"
+
+class FormSimpleImpl:public FormSimple {
+Q_OBJECT
+public:
+ FormSimpleImpl (Engine *e, QWidget * parent = 0, const char *name = 0)
+ :FormSimple (parent, name) {engine = e;engine->setRepresentation(rDouble);};
+
+ ~FormSimpleImpl () { };
+
+private:
+ Engine *engine;
+
+private slots:
+ void MPlusClicked();
+ void MCClicked();
+ void MRClicked();
+ void CEClicked();
+ void evalClicked();
+ void addClicked ();
+ void decimalClicked ();
+ void divClicked ();
+ void mulClicked ();
+ void subClicked ();
+ void val0Clicked ();
+ void val1Clicked ();
+ void val2Clicked ();
+ void val3Clicked ();
+ void val4Clicked ();
+ void val5Clicked ();
+ void val6Clicked ();
+ void val7Clicked ();
+ void val8Clicked ();
+ void val9Clicked ();
+};
+
+#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 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef STDINSTRUCTION_H
+#define STDINSTRUCTION_H
+
+#include <qpe/qmath.h>
+#include "instruction.h"
+
+// Useful instructions for plugin writers
+// If you use them, take note of their precedence
+class iAdd:public Instruction {
+public:
+ iAdd ():Instruction (10) { };
+ ~iAdd () { };
+ Data eval (Data num) {
+ Data result;
+ switch (rep) {
+ case rDouble:
+ result.dbl = acc.dbl + num.dbl;
+ break;
+ default:
+ result.i = acc.i + num.i;
+ };
+ return result;
+ };
+};
+class iSub:public Instruction {
+public:
+ iSub ():Instruction (10) { };
+ ~iSub () { };
+ Data eval (Data num) {
+ Data result;
+ switch (rep) {
+ case rDouble:
+ result.dbl = acc.dbl - num.dbl;
+ break;
+ default:
+ result.i = acc.i - num.i;
+ };
+ return result;
+ };
+};
+class iMul:public Instruction {
+public:
+ iMul ():Instruction (20) { };
+ ~iMul () { };
+ Data eval (Data num) {
+ Data result;
+ switch (rep) {
+ case rDouble:
+ result.dbl = acc.dbl * num.dbl;
+ break;
+ default:
+ result.i = acc.i * num.i;
+ };
+ return result;
+ };
+};
+class iDiv:public Instruction {
+public:
+ iDiv ():Instruction (20) { };
+ ~iDiv () { };
+ Data eval (Data num) {
+ Data result;
+ switch (rep) {
+ case rDouble:
+ result.dbl = acc.dbl / num.dbl;
+ break;
+ default:
+ result.i = acc.i / num.i;
+ };
+ return result;
+ };
+};
+
+// Immediate double instructions only
+class iSin:public Instruction {
+public:
+ iSin ():Instruction () { };
+ ~iSin () { };
+ Data eval (Data num) {
+ Data result;
+ result.dbl = qSin(num.dbl);
+ return result;
+ };
+};
+class iCos:public Instruction {
+public:
+ iCos ():Instruction () { };
+ ~iCos () { };
+ Data eval (Data num) {
+ Data result;
+ result.dbl = qCos(num.dbl);
+ return result;
+ };
+};
+class iTan:public Instruction {
+public:
+ iTan ():Instruction () { };
+ ~iTan () {};
+ Data eval (Data num) {
+ Data result;
+ result.dbl = qTan(num.dbl);
+ return result;
+ };
+};
+#endif