00001 /** $Revision: 1.4 $ 00002 Last updated: $Date: 2002/09/20 12:21:30 $ 00003 00004 Copyright (C) 2001-2002 Vlad Mereuta <dizzy@users.sourceforge.net> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00019 00020 #ifndef __CALC_FORM__ 00021 #define __CALC_FORM__ 00022 00023 #include <PalmOS.h> 00024 #include <FloatMgr.h> 00025 00026 #include "Form.h" 00027 00028 ///class implements a calculator 00029 class CalculatorForm : public Form 00030 { 00031 public: 00032 ///initial amount to be diplayed 00033 Int32 amount; 00034 ///sign of the amount memorised 00035 Int8 sign; 00036 00037 ///constructor, does nothing 00038 CalculatorForm() FORM_SECTION1; 00039 /** returns reference to SplitsForm instance. Only allowed way to use the class */ 00040 static CalculatorForm* instance() FORM_SECTION1; 00041 00042 private: 00043 ///current calculator entry 00044 Char entry[32]; 00045 ///text for decimal separator 00046 Char dotLabel[2]; 00047 FlpCompDouble accu; 00048 FlpCompDouble operand; 00049 Char operation; 00050 Boolean disp_accu; 00051 ///singleton reference to this form 00052 static CalculatorForm* _instance; 00053 00054 ///updates calculator display display 00055 void updateDisplay() FORM_SECTION1; 00056 ///redraws form and update display 00057 Boolean handleUpdateEvent(UInt16 update_code) FORM_SECTION1; 00058 ///draws initial calculator 00059 Boolean handleOpenEvent() FORM_SECTION1; 00060 ///handles all control interaction 00061 Boolean handleCtlSelectEvent (UInt16 control_id) FORM_SECTION1; 00062 ///update entry with information from a button 00063 void handleButton(Char c) FORM_SECTION1; 00064 ///carry out operation 00065 void doMath(Char newop) FORM_SECTION1; 00066 ///flip sign 00067 void flipSign(void) FORM_SECTION1; 00068 }; 00069 #endif