00001 /** $Revision: 1.21 $ 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 __EDIT_ACCOUNT_FORM__ 00021 #define __EDIT_ACCOUNT_FORM__ 00022 00023 #include <PalmOS.h> 00024 00025 #include "Form.h" 00026 #include "AccountsDB.h" 00027 #include "ChooseAccountForm.h" 00028 #include "NoteForm.h" 00029 00030 ///the form is used to create a new transaction or to modify an existing one, depending on the record_is_new member 00031 class EditAccountForm : public Form 00032 { 00033 public: 00034 ///constructor 00035 EditAccountForm(); 00036 00037 ///returns singleton reference to this object 00038 static EditAccountForm* instance() FORM_SECTION1; 00039 00040 void setRecordIsNew(Boolean b) { record_is_new = b; } 00041 /// callback for custom list drawing 00042 static void drawCurrencyItem(Int16 item_no, RectangleType* bounds, Char** txt) FORM_SECTION1; 00043 private: 00044 /// the selected category 00045 UInt16 selected_cat; 00046 ///buffer to store the parent name 00047 Char parent_name[55]; 00048 00049 ///holds the data being manipulated 00050 accountStructure account; 00051 ///handle to the currently edited account record (used for saving the record) 00052 MemHandle rech; 00053 ///previous parent of the account 00054 UInt32 prev_parent_uid; 00055 ///previous depth of the account 00056 UInt8 prev_depth; 00057 /// this is set to true if we want to create a new account and to false if we want the 'details' functionality 00058 Boolean record_is_new; 00059 ///contains the id of the last saved transaction 00060 UInt16 trans_id; 00061 ///local choose acc form 00062 ChooseAccountForm* choose_account_form; 00063 00064 ///reference to this object 00065 static EditAccountForm* _instance; 00066 00067 ///form to handle notes 00068 NoteForm* _note_form; 00069 00070 ///saves the changes to the database 00071 Boolean save() FORM_SECTION1; 00072 ///set the values of various form fields from the database 00073 void init() FORM_SECTION1; 00074 /** saves the data provided by ChooseAccountForm and updates the screen 00075 @param id of the account/category to be displayed */ 00076 void setParentAccount(UInt32 id) FORM_SECTION1; 00077 /// reflect change in account type selection on popup trigger and list 00078 void updateTypeSelection() FORM_SECTION1; 00079 /** set the currency trigger and selects the right item from currency list 00080 @param selection id of the currency to be selected */ 00081 void setCurrencyListSelection (UInt16 selection) FORM_SECTION1; 00082 /** updates the currency trigger by writing the text corresponding to a given selection 00083 @param selection ID of the currency to be displayed */ 00084 void updateCurPopupTrigger (UInt16 selection) FORM_SECTION1; 00085 00086 ///draws form and sets default values 00087 Boolean handleOpenEvent() FORM_SECTION1; 00088 /// event handler for controls in the form 00089 Boolean handleCtlSelectEvent(UInt16 control_id) FORM_SECTION1; 00090 ///handles form updating 00091 Boolean handleUpdateEvent(UInt16 update_code) FORM_SECTION1; 00092 ///sets value of record_is_new member 00093 /** handle the currency popup select event 00094 @param pop_select event data captured */ 00095 Boolean handlePopSelect (popSelect& pop_select) FORM_SECTION1; 00096 }; 00097 00098 00099 #endif