//**************************************************************************** // $Module type: CLASS // $Module name: cEntryGrid // $Author : Vincent Oorsprong // Created : 17/09/98 @ 15:55 // // Description // This class allows one to enter new rows // // $Rev History // 17/09/98 VO Module header created //**************************************************************************** Class cEntryGrid Is A Grid //**************************************************************************** // $Module type: PROCEDURE // $Module name: Construct_Object // $Author : Vincent Oorsprong // Created : 17/09/98 @ 15:55 // // Description // // $Rev History // 17/09/98 VO Module header created //**************************************************************************** Procedure Construct_Object Forward Send Construct_Object Property Integer pbAutoCreateEmptyRow Public Dffalse On_Key kDownArrow Send DoGoRowDown On_Key kDelete_Record Send DoDeleteCurrentRow End_Procedure // Construct_Object //**************************************************************************** // $Module type: PROCEDURE // $Module name: Add_Focus // $Author : Vincent Oorsprong // Created : 21/09/98 @ 9:01 // // Description // When the object of this class is added to the focus tree and the object // does not have any items will instruct it to add an empty row // // $Rev History // 21/09/98 VO Module header created //**************************************************************************** Procedure Add_Focus Integer hoRoot Forward Send Add_Focus hoRoot If (pbAutoCreateEmptyRow (Self) = Dftrue) Begin Send DoCheckIfGridIsEmpty End End_Procedure // Add_Focus //**************************************************************************** // $Module type: PROCEDURE // $Module name: DoCheckIfGridIsEmpty // $Author : Vincent Oorsprong // Created : 21/09/98 @ 9:25 // // Description // This method will make a new row when the grid contains no items // // $Rev History // 21/09/98 VO Module header created //**************************************************************************** Procedure DoCheckIfGridIsEmpty Integer iItems Get Item_Count To iItems If (iItems = 0) Begin Send DoAddRow End End_Procedure // DoCheckIfGridIsEmpty //**************************************************************************** // $Module type: FUNCTION // $Module name: IsRowEmpty // $Author : Vincent Oorsprong // Created : 21/09/98 @ 9:15 // // Description // This function will parse the items of a row and when one of the items // is not empty it will return false // // $Rev History // 21/09/98 VO Module header created //**************************************************************************** Function IsRowEmpty Integer iRow Integer iColumns Returns Integer Integer iStartItem iEndItem iItem String sValue Move (iRow * iColumns) To iStartItem Move (iStartItem + iColumns - 1) To iEndItem For iItem From iStartItem To iEndItem Get Value Item iItem To sValue If (sValue <> "") Begin Function_Return Dffalse End Loop Function_Return Dftrue End_Function // IsRowEmpty //**************************************************************************** // $Module type: PROCEDURE // $Module name: DoDeleteRow // $Author : Vincent Oorsprong // Created : 21/09/98 @ 9:19 // // Description // This method will delete the items of the passed row number // // $Rev History // 21/09/98 VO Module header created //**************************************************************************** Procedure DoDeleteRow Integer iRow Integer iColumns Integer iStartItem iEndItem iItem Move (iRow * iColumns) To iStartItem Move (iStartItem + iColumns - 1) To iEndItem For iItem From iStartItem To iEndItem Send Delete_Item iStartItem Loop End_Procedure // DoDeleteRow //**************************************************************************** // $Module type: PROCEDURE // $Module name: DoDeleteEmptyRows // $Author : Vincent Oorsprong // Created : 21/09/98 @ 9:12 // // Description // This method will run through all rows and when a row is empty it will // delete this // // $Rev History // 21/09/98 VO Module header created //**************************************************************************** Procedure DoDeleteEmptyRows Integer bOldDynamicUpdateState iRows iColumns iRow bRowIsEmpty iItems Get Dynamic_Update_State To bOldDynamicUpdateState Set Dynamic_Update_State To False Get Item_Count To iItems If (iItems > 0) Begin Get RowCount To iRows Get ColumnCount To iColumns For iRow From 0 To iRows Get IsRowEmpty iRow iColumns To bRowIsEmpty If (bRowIsEmpty = Dftrue) Begin Send DoDeleteRow iRow iColumns Decrement iRow Decrement iRows End Loop End If (pbAutoCreateEmptyRow (Self) = Dftrue) Begin Send DoCheckIfGridIsEmpty End Set Dynamic_Update_State To bOldDynamicUpdateState End_Procedure // DoDeleteEmptyRows //**************************************************************************** // $Module type: FUNCTION // $Module name: ColumnCount // $Author : Vincent Oorsprong // Created : 17/09/98 @ 16:03 // // Description // This function returns the number of columns in the grid // // $Rev History // 17/09/98 VO Module header created //**************************************************************************** Function ColumnCount Returns Integer Integer iMatrixSize iColumns Get Matrix_Size To iMatrixSize Move (Low (iMatrixSize)) To iColumns Function_Return iColumns End_Function // ColumnCount //**************************************************************************** // $Module type: FUNCTION // $Module name: RowCount // $Author : Vincent Oorsprong // Created : 17/09/98 @ 16:02 // // Description // This function returns the current number of rows in the grid // // $Rev History // 17/09/98 VO Module header created //**************************************************************************** Function RowCount Returns Integer Integer iColumns iItems iRows Get ColumnCount To iColumns Move (Item_Count (Self) - 1) To iItems Move (iItems / iColumns) To iRows Function_Return iRows End_Function // RowCount //**************************************************************************** // $Module type: PROCEDURE // $Module name: DoAddRow // $Author : Vincent Oorsprong // Created : 17/09/98 @ 16:05 // // Description // This method will add a row to the end of the grid // // $Rev History // 17/09/98 VO Module header created //**************************************************************************** Procedure DoAddRow Integer iColumn iColumns Get ColumnCount To iColumns For iColumn From 1 To iColumns Send Add_Item Msg_None "" End End_Procedure // DoAddRow //**************************************************************************** // $Module type: PROCEDURE // $Module name: DoGoRowDown // $Author : Vincent Oorsprong // Created : 17/08/98 @ 20:03 // // Description // This method will add an empty item to the list of items // // $Rev History // 17/09/98 Added row concept // 19/08/98 Procedure VO and body changed // 17/08/98 VO Module header created //**************************************************************************** Procedure DoGoRowDown Integer iItem iColumns iRows iRow Get RowCount To iRows Get ColumnCount To iColumns Get Current_Item To iItem Move (iItem / iColumns) To iRow If (iRow = iRows) Begin Send DoAddRow End Set Current_Item To (iItem + iColumns) End_Procedure // DoGoRowDown //**************************************************************************** // $Module type: PROCEDURE // $Module name: DoDeleteCurrentRow // $Author : Vincent Oorsprong // Created : 19/08/98 @ 12:22 // // Description // This method will remove the current row from the list of rows // // $Rev History // 21/09/98 VO of the procedure changed // 19/08/98 VO Module header created //**************************************************************************** Procedure DoDeleteCurrentRow Integer iColumns iItem iRow bOldDynamicUpdateState Get Dynamic_Update_State To bOldDynamicUpdateState Set Dynamic_Update_State To False Get ColumnCount To iColumns Get Current_Item To iItem Move (iItem / iColumns) To iRow Send DoDeleteRow iRow iColumns If (pbAutoCreateEmptyRow (Self) = Dftrue) Begin Send DoCheckIfGridIsEmpty End If (iItem > Item_Count (Self)) Begin Set Current_Item To (iItem - iColumns) End Set Dynamic_Update_State To bOldDynamicUpdateState End_Procedure // DoDeleteCurrentRow End_Class // cEntryGrid