summaryrefslogtreecommitdiff
path: root/noncore/tools/calculator
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/calculator
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'noncore/tools/calculator') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/calculator/.cvsignore4
-rw-r--r--noncore/tools/calculator/Makefile.in139
-rw-r--r--noncore/tools/calculator/calculator.pro13
-rw-r--r--noncore/tools/calculator/calculator.ui1026
-rw-r--r--noncore/tools/calculator/calculatorimpl.cpp601
-rw-r--r--noncore/tools/calculator/calculatorimpl.h135
-rw-r--r--noncore/tools/calculator/main.cpp35
-rw-r--r--noncore/tools/calculator/qpe-calculator.control10
8 files changed, 1963 insertions, 0 deletions
diff --git a/noncore/tools/calculator/.cvsignore b/noncore/tools/calculator/.cvsignore
new file mode 100644
index 0000000..f5bf2df
--- a/dev/null
+++ b/noncore/tools/calculator/.cvsignore
@@ -0,0 +1,4 @@
+moc_*
+Makefile
+calculator.h
+calculator.cpp
diff --git a/noncore/tools/calculator/Makefile.in b/noncore/tools/calculator/Makefile.in
new file mode 100644
index 0000000..d62b046
--- a/dev/null
+++ b/noncore/tools/calculator/Makefile.in
@@ -0,0 +1,139 @@
+#############################################################################
+
+####### Compiler, tools and options
+
+CXX = $(SYSCONF_CXX) $(QT_CXX_MT)
+CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
+CC = $(SYSCONF_CC) $(QT_C_MT)
+CFLAGS = $(SYSCONF_CFLAGS)
+INCPATH = -I$(QPEDIR)/include
+LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
+LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
+MOC = $(SYSCONF_MOC)
+UIC = $(SYSCONF_UIC)
+
+####### Target
+
+DESTDIR = $(QPEDIR)/bin/
+VER_MAJ = 1
+VER_MIN = 0
+VER_PATCH = 0
+TARGET = calculator
+TARGET1 = lib$(TARGET).so.$(VER_MAJ)
+
+####### Files
+
+HEADERS = calculatorimpl.h
+SOURCES = calculatorimpl.cpp \
+ main.cpp
+OBJECTS = calculatorimpl.o \
+ main.o \
+ calculator.o
+INTERFACES = calculator.ui
+UICDECLS = calculator.h
+UICIMPLS = calculator.cpp
+SRCMOC = moc_calculatorimpl.cpp \
+ moc_calculator.cpp
+OBJMOC = moc_calculatorimpl.o \
+ moc_calculator.o
+
+
+####### 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: $(DESTDIR)$(TARGET)
+
+$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
+ $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
+
+moc: $(SRCMOC)
+
+tmake:
+ tmake calculator.pro
+
+clean:
+ -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
+ -rm -f *~ core
+ -rm -f allmoc.cpp
+
+####### Extension Modules
+
+listpromodules:
+ @echo
+
+listallmodules:
+ @echo
+
+listaddonpromodules:
+ @echo
+
+listaddonentmodules:
+ @echo
+
+
+REQUIRES=
+
+####### Sub-libraries
+
+
+###### Combined headers
+
+
+
+####### Compile
+
+calculatorimpl.o: calculatorimpl.cpp \
+ calculatorimpl.h \
+ calculator.h \
+ $(QPEDIR)/include/qpe/resource.h \
+ $(QPEDIR)/include/qpe/qmath.h \
+ $(QPEDIR)/include/qpe/qpeapplication.h
+
+main.o: main.cpp \
+ calculatorimpl.h \
+ calculator.h \
+ $(QPEDIR)/include/qpe/qpeapplication.h
+
+calculator.h: calculator.ui
+ $(UIC) calculator.ui -o calculator.h
+
+calculator.cpp: calculator.ui
+ $(UIC) calculator.ui -i calculator.h -o calculator.cpp
+
+calculator.o: calculator.cpp \
+ calculator.h \
+ calculator.ui
+
+moc_calculatorimpl.o: moc_calculatorimpl.cpp \
+ calculatorimpl.h \
+ calculator.h
+
+moc_calculator.o: moc_calculator.cpp \
+ calculator.h
+
+moc_calculatorimpl.cpp: calculatorimpl.h
+ $(MOC) calculatorimpl.h -o moc_calculatorimpl.cpp
+
+moc_calculator.cpp: calculator.h
+ $(MOC) calculator.h -o moc_calculator.cpp
+
+
diff --git a/noncore/tools/calculator/calculator.pro b/noncore/tools/calculator/calculator.pro
new file mode 100644
index 0000000..1281fd5
--- a/dev/null
+++ b/noncore/tools/calculator/calculator.pro
@@ -0,0 +1,13 @@
+DESTDIR = $(QPEDIR)/bin
+TEMPLATE = app
+CONFIG = qt warn_on release
+HEADERS = calculatorimpl.h
+SOURCES = calculatorimpl.cpp \
+ main.cpp
+INCLUDEPATH += $(QPEDIR)/include
+DEPENDPATH += $(QPEDIR)/include
+LIBS += -lqpe
+INTERFACES = calculator.ui
+TARGET = calculator
+
+TRANSLATIONS = ../i18n/de/calculator.ts
diff --git a/noncore/tools/calculator/calculator.ui b/noncore/tools/calculator/calculator.ui
new file mode 100644
index 0000000..e8218ab
--- a/dev/null
+++ b/noncore/tools/calculator/calculator.ui
@@ -0,0 +1,1026 @@
+<!DOCTYPE UI><UI>
+<class>Calculator</class>
+<comment>*********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qt Palmtop 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.
+**
+*********************************************************************</comment>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Calculator</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>271</width>
+ <height>404</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>32767</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>baseSize</name>
+ <size>
+ <width>235</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Experimental Calculator</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget>
+ <class>QLCDNumber</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>LCD</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <pointsize>7</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>numDigits</name>
+ <number>15</number>
+ </property>
+ <property stdset="1">
+ <name>segmentStyle</name>
+ <enum>Flat</enum>
+ </property>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout4</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget>
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>ComboBoxFunction</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonMPlus</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>M+</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonMR</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>MR</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonMC</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>MC</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonCE</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>CE</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout10</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF6</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF7</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF8</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>log</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF9</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>ln</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF11</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>(</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF12</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>)</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout11</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF1</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>sin</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF2</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>cos</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF3</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>tan</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF4</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF5</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>%</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonF10</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>+/-</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout5</cstring>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget row="2" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton3</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>3</string>
+ </property>
+ </widget>
+ <widget row="1" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton6</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>6</string>
+ </property>
+ </widget>
+ <widget row="3" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonEquals</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>=</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton0</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>0</string>
+ </property>
+ </widget>
+ <widget row="1" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonMinus</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </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>PushButtonTimes</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>x</string>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton4</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>4</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton8</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>8</string>
+ </property>
+ </widget>
+ <widget row="3" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonDivide</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>/</string>
+ </property>
+ </widget>
+ <widget row="0" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonAdd</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>+</string>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton1</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>1</string>
+ </property>
+ </widget>
+ <widget row="3" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButtonDecimal</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>.</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton5</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>5</string>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton7</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>7</string>
+ </property>
+ </widget>
+ <widget row="0" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton9</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>9</string>
+ </property>
+ </widget>
+ <widget row="2" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PushButton2</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <family>adobe-helvetica</family>
+ <pointsize>24</pointsize>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>focusPolicy</name>
+ <enum>TabFocus</enum>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>2</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<tabstops>
+ <tabstop>ComboBoxFunction</tabstop>
+ <tabstop>PushButtonMPlus</tabstop>
+ <tabstop>PushButtonMR</tabstop>
+ <tabstop>PushButtonMC</tabstop>
+ <tabstop>PushButtonCE</tabstop>
+ <tabstop>PushButtonF6</tabstop>
+ <tabstop>PushButtonF7</tabstop>
+ <tabstop>PushButtonF8</tabstop>
+ <tabstop>PushButtonF9</tabstop>
+ <tabstop>PushButtonF11</tabstop>
+ <tabstop>PushButtonF12</tabstop>
+ <tabstop>PushButtonF1</tabstop>
+ <tabstop>PushButtonF2</tabstop>
+ <tabstop>PushButtonF3</tabstop>
+ <tabstop>PushButtonF4</tabstop>
+ <tabstop>PushButtonF5</tabstop>
+ <tabstop>PushButtonF10</tabstop>
+ <tabstop>PushButton7</tabstop>
+ <tabstop>PushButton8</tabstop>
+ <tabstop>PushButton9</tabstop>
+ <tabstop>PushButtonAdd</tabstop>
+ <tabstop>PushButton4</tabstop>
+ <tabstop>PushButton5</tabstop>
+ <tabstop>PushButton6</tabstop>
+ <tabstop>PushButtonMinus</tabstop>
+ <tabstop>PushButton1</tabstop>
+ <tabstop>PushButton2</tabstop>
+ <tabstop>PushButton3</tabstop>
+ <tabstop>PushButtonTimes</tabstop>
+ <tabstop>PushButton0</tabstop>
+ <tabstop>PushButtonDecimal</tabstop>
+ <tabstop>PushButtonEquals</tabstop>
+ <tabstop>PushButtonDivide</tabstop>
+</tabstops>
+</UI>
diff --git a/noncore/tools/calculator/calculatorimpl.cpp b/noncore/tools/calculator/calculatorimpl.cpp
new file mode 100644
index 0000000..2f7d7ce
--- a/dev/null
+++ b/noncore/tools/calculator/calculatorimpl.cpp
@@ -0,0 +1,601 @@
+/**********************************************************************
+** 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 "calculatorimpl.h"
+
+#include <qpe/resource.h>
+#include <qpe/qmath.h>
+#include <qpe/qpeapplication.h>
+
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qfont.h>
+#include <qlayout.h>
+#include <qstringlist.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qmessagebox.h>
+#include <math.h>
+
+CalculatorImpl::CalculatorImpl( QWidget * parent, const char * name,
+ WFlags f )
+ : Calculator( parent, name, f )
+{
+ xtopowerofy = Resource::loadPixmap("xtopowerofy");
+ ythrootofx = Resource::loadPixmap("ythrootofx");
+ oneoverx = Resource::loadPixmap("oneoverx");
+
+ memMark = new QLabel( "m", LCD );
+ memMark->setFont( QFont( "helvetica", 12, QFont::Bold, TRUE ) );
+ memMark->resize( 12, 12 );
+ memMark->move( 4, 2 );
+ memMark->hide();
+ mem = 0;
+
+ PushButtonMR->setEnabled( FALSE );
+
+ current_mode = max_mode = conversion_mode_count = 0;
+ last_conversion = -1;
+
+//bgr_command.insert( PushButtonFunction);
+ bgr_command.insert( PushButtonMPlus);
+ bgr_command.insert( PushButtonMR);
+ bgr_command.insert( PushButtonMC);
+ bgr_command.insert( PushButtonCE);
+ connect( &bgr_command, SIGNAL(clicked(int) ), this, SLOT(command_buttons(int)));
+
+ bgr_digits.insert(PushButton0);
+ bgr_digits.insert(PushButton1);
+ bgr_digits.insert(PushButton2);
+ bgr_digits.insert(PushButton3);
+ bgr_digits.insert(PushButton4);
+ bgr_digits.insert(PushButton5);
+ bgr_digits.insert(PushButton6);
+ bgr_digits.insert(PushButton7);
+ bgr_digits.insert(PushButton8);
+ bgr_digits.insert(PushButton9);
+ connect( &bgr_digits, SIGNAL(clicked(int) ), this, SLOT(enterNumber(int)));
+
+
+ bgr_std.insert(PushButtonEquals);
+ bgr_std.insert(PushButtonDecimal);
+ bgr_std.insert(PushButtonAdd);
+ bgr_std.insert(PushButtonMinus);
+ bgr_std.insert(PushButtonDivide);
+ bgr_std.insert(PushButtonTimes);
+ connect( &bgr_std, SIGNAL(clicked(int) ), this, SLOT(std_buttons(int)));
+
+// change the / to a proper division signal
+ PushButtonDivide->setText(QChar(0xF7));
+
+ func_buttons[0] = PushButtonF1;
+ func_buttons[1] = PushButtonF2;
+ func_buttons[2] = PushButtonF3;
+ func_buttons[3] = PushButtonF4;
+ func_buttons[4] = PushButtonF5;
+ func_buttons[5] = PushButtonF6;
+ func_buttons[6] = PushButtonF7;
+ func_buttons[7] = PushButtonF8;
+ func_buttons[8] = PushButtonF9;
+ func_buttons[9] = PushButtonF10;
+ func_buttons[10] = PushButtonF11;
+ func_buttons[11] = PushButtonF12;
+
+ for ( int x = 0 ; x < func_button_count ; x++ ) {
+ QPushButton* tmpbutton = func_buttons[x];
+ faces << tmpbutton->text();
+ bgr_function.insert(tmpbutton);
+ }
+ connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(do_convert(int) ) );
+ connect( &bgr_function, SIGNAL(clicked(int) ) , this, SLOT(std_funcs (int) ) );
+
+ connect(ComboBoxFunction, SIGNAL(activated(int) ), this, SLOT(function_button(int) ) );
+
+ captions.append("Standard");
+ ComboBoxFunction->insertItem(captions.last());
+
+ // now add in the conversion modes
+ // when the menu gets done, these should be in a submenu
+ QString tmp = QPEApplication::qpeDir();
+ tmp += "/etc/unit_conversion.dat";
+ QFile myfile(tmp);
+ if ( !myfile.open( IO_Translate | IO_ReadOnly ) ) {
+ // QMessageBox::warning(this, "Warning", "Data file\nunit_conversion.dat\nnot found\nNo conversion\nfeatures will\nbe available");
+ // disable the f button if no conv file available
+ ComboBoxFunction->setEnabled(FALSE);
+ }
+ else {
+ QString line, line2;
+ QTextStream ts(&myfile);
+
+ // first pass, see how many conversion types there are in order to allocate for them
+ while ( ! ts.eof() ) {
+ line = ts.readLine();
+ if ( line.contains ("STARTTYPE" ) )
+ conversion_mode_count++;
+ }
+
+ entry_list = new double[conversion_mode_count*func_button_count];
+
+ myfile.close();
+ myfile.open( IO_Translate | IO_ReadOnly );
+ QTextStream ts2(&myfile);
+
+ // second pass, read in values
+ int x = 0;
+ while ( ! ts2.eof() ) {
+ line = ts2.readLine();
+ if ( line.contains("STARTTYPE") ) {
+ captions << line.remove(0,10);
+ ComboBoxFunction->insertItem(captions.last());
+ while ( !line.contains("ENDTYPE") ) {
+ line = ts2.readLine();
+ if ( line.contains("NAME") ) {
+ faces << line.remove(0,5);
+ line2 = ts2.readLine();
+ line2.remove(0,6);
+ entry_list[x] = line2.toDouble();
+ x++;
+ }
+ }
+ }
+ }
+ }
+ myfile.close();
+ clear();
+ max_mode = pre_conv_modes_count + conversion_mode_count + post_conv_modes_count - 1;
+ display_pixmap_faces();
+
+ qApp->installEventFilter( this );
+}
+
+bool CalculatorImpl::eventFilter( QObject *o, QEvent *e )
+{
+ if ( e->type() == QEvent::KeyPress && state != sError ) {
+ QKeyEvent *k = (QKeyEvent*)e;
+ if ( k->key() >= Key_0 && k->key() <= Key_9 ) {
+ enterNumber( k->key() - Key_0 );
+ return true;
+ } else {
+ switch ( k->key() ) {
+ case Key_Equal:
+ std_buttons(0);
+ return true;
+ case Key_Period:
+ std_buttons(1);
+ return true;
+ case Key_Plus:
+ std_buttons(2);
+ return true;
+ case Key_Minus:
+ std_buttons(3);
+ return true;
+ case Key_Slash:
+ std_buttons(4);
+ return true;
+ case Key_Asterisk:
+ std_buttons(5);
+ return true;
+ case Key_Percent:
+ execOp( oPercent );
+ return true;
+ case Key_ParenLeft:
+ if ( current_mode < pre_conv_modes_count )
+ execOp( oOpenBrace );
+ return true;
+ case Key_ParenRight:
+ if ( current_mode < pre_conv_modes_count )
+ execOp( oCloseBrace );
+ return true;
+ default:
+ break;
+ }
+ }
+ }
+ return Calculator::eventFilter( o, e );
+}
+
+void CalculatorImpl::do_convert(int button) {
+ if ( state == sError )
+ return;
+ if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) &&
+ button < changeable_func_button_count ) {
+ if ( last_conversion > -1 ) {
+ if( state == sNewNumber ){
+ acc = num
+ / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
+ * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) ;
+ num = acc;
+ LCD->display( acc );
+ } else {
+ state = sNewNumber;
+ num = num
+ / (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + last_conversion])
+ * (entry_list[(current_mode - pre_conv_modes_count) * func_button_count + button]) ;
+ LCD->display( num );
+ acc = num;
+ }
+ }
+ last_conversion = button;
+ }
+}
+
+
+void CalculatorImpl::function_button(int mode){
+ if ( state == sError )
+ clear();
+ // dont need the next line when using a popup menu
+ current_mode = mode;
+
+ // reset the last conv
+ last_conversion = -1;
+
+ // set the caption
+ this->setCaption( captions[current_mode] );
+
+ reset_conv();
+
+ for ( int x = 0 ; x < changeable_func_button_count ; x++ ) {
+ QPushButton* tmpbutton = func_buttons[x];
+
+ // if its a conversion , make it a toggle button
+ if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) {
+ tmpbutton->setToggleButton(TRUE);
+ } else {
+ tmpbutton->setToggleButton(FALSE);
+ }
+ tmpbutton->setText( faces[current_mode * func_button_count + x] );
+ }
+
+ if ( current_mode == 0 ) display_pixmap_faces();
+
+ if ( current_mode >= pre_conv_modes_count && current_mode <= (max_mode - post_conv_modes_count) ) {
+ bgr_function.setExclusive(TRUE);
+ } else {
+ bgr_function.setExclusive(FALSE);
+ }
+}
+
+void CalculatorImpl::display_pixmap_faces() {
+ QPushButton* tmpbutton = func_buttons[5];
+ tmpbutton->setPixmap(xtopowerofy);
+
+ tmpbutton = func_buttons[6];
+ tmpbutton->setPixmap(ythrootofx);
+
+ tmpbutton = func_buttons[3];
+ tmpbutton->setPixmap(oneoverx);
+}
+
+void CalculatorImpl::clear() {
+ acc = num = 0;
+ operationStack.clear();
+ state = sStart;
+ numDecimals = 0;
+ numOpenBraces = 0;
+ flPoint = FALSE;
+ LCD->display( 0 );
+ fake = QString::null;
+
+ reset_conv();
+}
+
+void CalculatorImpl::reset_conv() {
+ for ( int x = 0 ; x < changeable_func_button_count ; x++ ) {
+ QPushButton* tmpbutton = func_buttons[x];
+
+ // dont carry any selections into the next mode
+ if ( tmpbutton->state() == QPushButton::On ) {
+ tmpbutton->toggle();
+ }
+ }
+
+ last_conversion = -1;
+}
+
+void CalculatorImpl::std_buttons(int button)
+{
+ if ( state == sError )
+ return;
+ execOp( (Operation)(button + oSum) );
+}
+
+void CalculatorImpl::std_funcs(int button) {
+ if ( state == sError )
+ return;
+ if ( current_mode < pre_conv_modes_count ||
+ button > changeable_func_button_count-1 ) {
+ Operation op;
+ if ( button < 10 )
+ op = (Operation)(button + oSin);
+ else if ( button == 10 )
+ op = oOpenBrace;
+ else
+ op = oCloseBrace;
+ execOp( op );
+ }
+}
+
+void CalculatorImpl::execOp( Operation i )
+{
+ switch (i) {
+ // these operators only affect the current number.
+ case oDivX:
+ case oLog:
+ case oLn:
+ case oSin:
+ case oCos:
+ case oTan:
+ num = evalExpr(i);
+ break;
+
+ case oAdd:
+ case oSub: {
+ processStack( oAdd );
+ Op op( num, i );
+ operationStack.push( op );
+ break;
+ }
+ case oDiv:
+ case oMult:
+ case oRoot:
+ case oXsquared: {
+ processStack( oDiv );
+ Op op( num, i );
+ operationStack.push( op );
+ break;
+ }
+ case oChSign:
+ num = -num;
+ LCD->display(num);
+ return;
+
+ case oOpenBrace: {
+ Op op( 0, oOpenBrace );
+ operationStack.push( op );
+ numOpenBraces++;
+ state = sNewNumber;
+ return;
+ }
+ case oCloseBrace: {
+ if ( numOpenBraces == 0 )
+ return;
+ processStack( oAdd );
+ if ( operationStack.top().operation != oOpenBrace )
+ qDebug( "Calculator: internal Error" );
+ operationStack.pop();
+ state = sNewNumber;
+ numOpenBraces--;
+ break;
+ }
+
+ case oPoint:
+ flPoint = TRUE;
+ return;
+
+ case oPercent:
+ processStack( oPercent );
+ break;
+
+
+ case oSum:
+ processStack( oSum );
+ break;
+
+ default:
+ return;
+ };
+
+ if ( state == sError ) {
+ LCD->display( "Error" );
+ return;
+ } else {
+ LCD->display(num);
+ }
+ state = sNewNumber;
+ numDecimals = 0;
+ flPoint = FALSE;
+}
+
+
+void CalculatorImpl::processStack( int op )
+{
+ //dubious percent hack, since the changeable operator precedences are
+ //pretty much hardwired to be less than the non-changeable
+ bool percent = FALSE;
+ if ( op == oPercent ) {
+ percent = TRUE;
+ op = oSum;
+ }
+ while( !operationStack.isEmpty() && operationStack.top().operation >= op ) {
+ Op operation = operationStack.pop();
+ acc = operation.number;
+ if ( percent ) {
+ if ( operation.operation == oAdd || operation.operation == oSub )
+ num = acc*num/100;
+ else
+ num = num / 100;
+ }
+ num = evalExpr( operation.operation );
+ percent = FALSE;
+ }
+}
+
+
+double CalculatorImpl::evalExpr( int op ) {
+ double sum = 0;
+
+ switch( op ){
+ case oPercent: sum = num / 100.; break;
+ case oDivX:
+ if (num == 0)
+ state = sError;
+ else
+ sum = 1 / num;
+ break;
+ case oXsquared:
+ sum = pow(acc,num);
+ break;
+ case oChSign: (state == sStart) ? sum = -num : sum = -acc; break;
+ case oSub: sum = acc - num; break;
+ case oMult: sum = acc * num; break;
+ case oAdd: sum = acc + num; break;
+ case oDiv: {
+ if (num == 0) {
+ state = sError;
+ } else {
+ sum = acc / num;
+ }
+ break;
+ }
+ case oRoot:
+ /* the linux library is dumb, and can't to -x to 1/n
+ when n is odd. (even and error of course is acceptable */
+ if((acc < 0) && (int(num) == num) && (int(num) % 2 == 1 )) {
+ sum = pow(-acc, 1 / num);
+ sum = -sum;
+ } else {
+ sum = pow(acc, 1 / num);
+ }
+ break;
+ case oLog:
+ sum = log10(num);
+ break;
+ case oLn:
+ sum = log(num);
+ break;
+ case oTan: sum = qTan(num);break;
+ case oSin: sum = qSin(num);break;
+ case oCos: sum = qCos(num);break;
+ default: sum = num; break;
+ }
+
+ if ( isinf( sum ) || isnan( sum ) )
+ state = sError;
+ return sum;
+}
+
+
+void CalculatorImpl::enterNumber( int n )
+{
+ if ( state == sError )
+ return;
+ if( state == sStart ){
+ if( LCD->value() > 0 ){
+ QString s = QString::number( LCD->value(), 'g', LCD->numDigits());
+ if( s.length() > (uint)(LCD->numDigits() - 2)) return;
+
+ } else if( (int)fake.length() >= LCD->numDigits() || numDecimals >=12 ){
+ return;
+ }
+ }
+
+ if( state == sNewNumber ){
+ state = sStart;
+ acc = 0;
+ if( flPoint ){
+ numDecimals = 1;
+ num = n / pow(10, numDecimals);
+ } else
+ num = n;
+ } else if( flPoint ){
+ numDecimals++;
+ if( num < 0 ){
+ num -= n / pow(10, numDecimals);
+ } else {
+ num += n / pow(10, numDecimals);
+ }
+ } else {
+ num *= 10;
+ if( num < 0 )
+ num -= n;
+ else
+ num += n;
+ }
+
+ // We need feedback in the calc display while entering fl.point zeros.
+ // This is a small hack to display sequences like: 0.000 and 1.100
+ double integer, fraction;
+ fraction = modf( num, &integer );
+ if( flPoint ){
+ QString is, fs, zeros;
+
+ is = QString::number( integer, 'g', 13 );
+ fs = QString::number( fraction, 'g', numDecimals );
+ if( fs.contains('e') ){
+ fs = QString::number( fraction, 'f', LCD->numDigits() );
+ }
+ fs = fs.mid( 2, numDecimals );
+
+ if( (integer == 0) && (fraction == 0) )
+ fake = "0.";
+ else if( (integer != 0) && (fraction == 0) )
+ fake = is + ".";
+ else
+ fake = is + "." + fs;
+
+ zeros.fill( '0', (numDecimals - fs.length()) );
+ fake += zeros;
+ // ### This code sets LCD->value() to zero since it sets a text
+ // ### Avoid getting the current value from LCD->value() for
+ // ### calculations.
+ LCD->display( fake );
+ } else
+ LCD->display( num );
+}
+
+void CalculatorImpl::command_buttons(int i) {
+ if ( state == sError && i != 3 )
+ return;
+ switch (i) {
+ case 0: // M+
+ mem += num;
+ if( mem != 0 ){
+ memMark->show();
+ PushButtonMR->setEnabled( TRUE ); };
+ state = sNewNumber;
+ break;
+ case 1: // MR
+ acc = num = mem;
+ state = sNewNumber;
+ LCD->display( mem );
+ break;
+ case 2: // MC
+ mem = 0;
+ memMark->hide();
+ PushButtonMR->setEnabled( FALSE );
+ break;
+ case 3: // CE
+ if ( state == sStart ) {
+ // clear the entered number on the first press
+ state = sNewNumber;
+ num = acc = 0;
+ flPoint = FALSE;
+ LCD->display( 0 );
+ fake = QString::null;
+ numDecimals = 0;
+ } else {
+ clear();
+ }
+ break;
+ };
+
+}
diff --git a/noncore/tools/calculator/calculatorimpl.h b/noncore/tools/calculator/calculatorimpl.h
new file mode 100644
index 0000000..bfb726f
--- a/dev/null
+++ b/noncore/tools/calculator/calculatorimpl.h
@@ -0,0 +1,135 @@
+/**********************************************************************
+** 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 CALCULATORIMPL_H
+#define CALCULATORIMPL_H
+
+
+#include <qlcdnumber.h>
+#include "calculator.h"
+#include <qpushbutton.h>
+#include <qbuttongroup.h>
+#include <qvaluestack.h>
+
+// mode x functions
+enum Operation {
+ oNop,
+ oOpenBrace,
+ oCloseBrace,
+ oSum,
+ oPoint,
+ oAdd,
+ oSub,
+ oDiv,
+ oMult,
+
+// mode 0 functions
+ oSin,
+ oCos,
+ oTan,
+ oDivX,
+ oPercent,
+ oXsquared,
+ oRoot,
+ oLog,
+ oLn,
+ oChSign
+};
+
+// states
+#define sStart 0
+#define sNewNumber 1
+#define sError 2
+
+struct Op
+{
+ Op() { number = 0; operation = oNop; }
+ Op( double num, Operation op )
+ { number = num; operation = op; }
+ double number;
+ Operation operation;
+};
+
+class QLabel;
+class CalculatorImpl : public Calculator
+{
+ Q_OBJECT
+
+public:
+ CalculatorImpl( QWidget * parent = 0, const char * name = 0,
+ WFlags f = 0 );
+
+public slots:
+ void command_buttons(int);
+ void enterNumber(int i);
+ void std_buttons(int);
+ void std_funcs(int);
+ void do_convert(int);
+ void function_button(int);
+
+protected:
+ virtual bool eventFilter( QObject *o, QEvent *e );
+
+private:
+ void clear();
+
+ void reset_conv();
+
+ void processStack( int op );
+
+ QValueStack<Op> operationStack;
+ int state;
+
+ double acc, num, mem;
+ int numDecimals;
+ bool flPoint;
+ int numOpenBraces;
+
+ void execOp( Operation i );
+ double evalExpr( int op );
+ QLabel * memMark;
+ QString fake;
+
+ // useful values for conversion stuff
+ int current_mode, max_mode, conversion_mode_count, last_conversion;
+
+ // make adding new modes easier for ourselves
+ static const int pre_conv_modes_count = 1;
+ static const int post_conv_modes_count = 0;
+
+ // an array of pointers to the func buttons
+ static const int func_button_count = 12;
+ // this is an abomination
+ static const int changeable_func_button_count = 10;
+ QPushButton* func_buttons[func_button_count];
+
+ QButtonGroup bgr_function, bgr_digits, bgr_std, bgr_command;
+ QStringList faces, captions;
+
+ // an array of doubles holding the conversion ratios
+ double* entry_list;
+
+ QPixmap xtopowerofy;
+ QPixmap ythrootofx;
+ QPixmap oneoverx;
+
+ void display_pixmap_faces(void);
+};
+
+#endif
diff --git a/noncore/tools/calculator/main.cpp b/noncore/tools/calculator/main.cpp
new file mode 100644
index 0000000..74cd5d3
--- a/dev/null
+++ b/noncore/tools/calculator/main.cpp
@@ -0,0 +1,35 @@
+/**********************************************************************
+** 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 "calculatorimpl.h"
+
+#include <qpe/qpeapplication.h>
+
+int main( int argc, char ** argv )
+{
+ QPEApplication a( argc, argv );
+
+ CalculatorImpl mw;
+ QPEApplication::setInputMethodHint( &mw, QPEApplication::AlwaysOff );
+ mw.setCaption( CalculatorImpl::tr("Calculator") );
+ a.showMainWidget( &mw );
+
+ return a.exec();
+}
diff --git a/noncore/tools/calculator/qpe-calculator.control b/noncore/tools/calculator/qpe-calculator.control
new file mode 100644
index 0000000..afef70b
--- a/dev/null
+++ b/noncore/tools/calculator/qpe-calculator.control
@@ -0,0 +1,10 @@
+Files: bin/calculator apps/Applications/calculator.desktop etc/unit_conversion.dat
+Priority: optional
+Section: qpe/applications
+Maintainer: Warwick Allison <warwick@trolltech.com>
+Architecture: arm
+Version: $QPE_VERSION-3
+Depends: qpe-base ($QPE_VERSION)
+Description: Calculator
+ A multi-function calculator for the Qtopia environment.
+ Includes units conversion.