00001 /** $Revision: 1.8 $ 00002 Last updated: $Date: 2002/09/20 12:21:31 $ 00003 00004 Copyright (C) 2000-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 __SPLITS_FORM__ 00021 #define __SPLITS_FORM__ 00022 00023 #include <PalmOS.h> 00024 #include "Form.h" 00025 #include "SplitsTable.h" 00026 #include "EditSplitForm.h" 00027 00028 /** Class used to handle Split managment */ 00029 class SplitsForm : public Form 00030 { 00031 public: 00032 ///constructor - initializes variables 00033 SplitsForm() FORM_SECTION2; 00034 ///destructor - disposes of allocated memory 00035 ~SplitsForm() FORM_SECTION2; 00036 00037 /** returns reference to SplitsForm instance. Only allowed way to use the class */ 00038 static SplitsForm* instance() FORM_SECTION2; 00039 00040 /// @return value of splits_count 00041 UInt16 getCount() FORM_SECTION2; 00042 00043 /** sets the value of splits_count; also updates the total_debits and credits variables */ 00044 void setCount(UInt8 count) FORM_SECTION2; 00045 00046 /** returns the account associated with a given split 00047 @param index split index to get the account for 00048 @return uid of the account for given split */ 00049 UInt32 getAccount(UInt8 index) FORM_SECTION2; 00050 00051 /** sets the account associated with a given split index 00052 @param index split index to modify the account for 00053 @param acc_uid new account uid */ 00054 void setAccount(UInt8 index, UInt32 acc_uid) FORM_SECTION2; 00055 00056 /** returns the amount associated with a given split index 00057 @param index split index to get the amount for 00058 @return amount for given split index */ 00059 Int32 getAmount(UInt8 index) FORM_SECTION2; 00060 00061 /** sets the amount associated with a given split index 00062 @param index index of the split to modify the amount for 00063 @param amount new amount */ 00064 void setAmount(UInt8 index, Int32 amount) FORM_SECTION2; 00065 00066 /** deletes a given split 00067 @param index of the split to delete */ 00068 void deleteSplit(UInt8 index) FORM_SECTION2; 00069 00070 /** deletes all splits 00071 @warning for some reason this method breaks horribly if placed in FORM_SECTION2!*/ 00072 void deleteAllSplits() FORM_SECTION2; 00073 00074 ///handles update events (public in order to be able to force updates) 00075 Boolean handleUpdateEvent (UInt16 update_code) FORM_SECTION2; 00076 00077 private: 00078 /// table used to display and select splits 00079 SplitsTable splits_tbl; 00080 ///total number of splits for current transaction 00081 UInt8 splits_count; 00082 /// handle to memory area containing the array of splits 00083 MemHandle splits_data; 00084 ///total for debit splits 00085 UInt32 total_debits; 00086 ///total for credit splits 00087 UInt32 total_credits; 00088 ///object handling particular split editing 00089 EditSplitForm edit_split_form; 00090 ///singleton reference to this form 00091 static SplitsForm* _instance; 00092 00093 ///draws form and table 00094 Boolean handleOpenEvent() FORM_SECTION2; 00095 ///handles pgup/down keys 00096 Boolean handleKeyDownEvent (WChar key_id, UInt16 modifiers) FORM_SECTION2; 00097 ///handles form controls 00098 Boolean handleCtlSelectEvent (UInt16 control_id) FORM_SECTION2; 00099 /** checks whether the given split index is valid 00100 @param index split index to check 00101 @return true if valid, false otherwise */ 00102 Boolean checkIndex(UInt8 index) FORM_SECTION2; 00103 ///handles table events 00104 Boolean handleTblSelectEvent(tblSelect& tbl_select) FORM_SECTION2; 00105 }; 00106 00107 #endif