//**************************************************************************** // $Module type: Package // $Module name: cRDCProjectIniFile.pkg // // $Author : Nils Svedmyr, RDC Tools International. // Copyright (c) 2012 RDC Tools International // E-mail : support@rdctools.com // Web-site : http://www.rdctools.com // // Created : 2012-09-20 @ 18:04 (Military date format - Year-Month-Day) // // The code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // This is free software; you can redistribute it and/or modify it under the terms of the // GNU Lesser General Public License - see the "GNU Lesser General Public License.txt" // in the help folder for more details. // Use cCJGrid.pkg Use cRDCProjectIniFile.pkg Class cRDCCJGrid is a cCJGrid Procedure Construct_Object Forward Send Construct_Object Set pbHeaderReorders to True Set pbHeaderTogglesDirection to True // Set to true if an descending index is in use Property Boolean pbDescendingIndexInUse False // If you quickly double-right-click, or quickly click around a cCJGrid // (using a combination of middle-clicks, right-clicks and left-clicks), the application can crash. // To guard against this see the augmented procedure OnComRowRClick below. Property Boolean pbRightClickProcessing False Property Boolean pbEnableMoveKeys False On_Key Key_Alt+Key_Down_Arrow Send MoveDown On_Key Key_Alt+Key_Up_Arrow Send MoveUp End_Procedure Procedure End_Construct_Object Forward Send End_Construct_Object End_Procedure Procedure MoveUp tDataSourceRow[] TheData tDataSourceRow TheRow Handle hDataSource Integer iCurrentRow If (pbEnableMoveKeys(Self) = False) Begin Procedure_Return End Get phoDataSource to hDataSource Get DataSource of hDataSource to TheData Get SelectedRow of hDataSource to iCurrentRow If (iCurrentRow > 0) Begin Move TheData[iCurrentRow - 1] to TheRow Move TheData[iCurrentRow] to TheData[iCurrentRow - 1] Move TheRow to TheData[iCurrentRow] Send ReInitializeData TheData True Send MoveToRow (iCurrentRow - 1) End End_Procedure Procedure MoveDown tDataSourceRow[] TheData tDataSourceRow TheRow Handle hDataSource Integer iCurrentRow If (pbEnableMoveKeys(Self) = False) Begin Procedure_Return End Get phoDataSource to hDataSource Get DataSource of hDataSource to TheData Get SelectedRow of hDataSource to iCurrentRow If ((iCurrentRow + 1) < SizeOfArray(TheData)) Begin Move TheData[iCurrentRow] to TheRow Move TheData[iCurrentRow + 1] to TheData[iCurrentRow] Move TheRow to TheData[iCurrentRow + 1] Send ReInitializeData TheData True Send MoveToRow (iCurrentRow + 1) End End_Procedure // When changing row, update the footer text Procedure OnRowChanged Integer iOldRow Integer iNewSelectedRow Forward Send OnRowChanged iOldRow iNewSelectedRow // Make sure we don't try to set the row colors before the // grid object has been actived and the dialog has been activated. If (iOldRow <> -1 and iNewSelectedRow <> 0) Begin Send DoSetCurrentRow End End_Procedure // Set row color & Alternate Row Background Color state. Procedure DoSetCurrentRow String sState sColor If (ghoProjectIniFile = 0) Begin Procedure_Return End Get IniFileValue of ghoProjectIniFile (psSectionName(ghoProjectIniFile)) CS_UseHighlightstateText CS_BooleanNo to sState Get IniFileValue of ghoProjectIniFile (psSectionName(ghoProjectIniFile)) CS_HighlightColorText clAqua to sColor If (sState = CS_BooleanYes) Begin Set pbSelectionEnable to True Set piHighlightBackColor to (Eval(sColor)) End Else Begin Set pbSelectionEnable to False Set piHighlightBackColor to (Eval(clWhite)) End Get IniFileValue of ghoProjectIniFile (psSectionName(ghoProjectIniFile)) CS_pbAlternateRowColor CS_BooleanYes to sState Set pbUseAlternateRowBackgroundColor to (sState = CS_BooleanYes) End_Procedure // Redisplay the grid records around the current record. // If the record no longer exists or no longer conforms to the current constraints // this will redisplay the records with the same iOffset. // If both finds fail the grid will not be updated so we need to clear it. Procedure RefreshGrid Send Find to (Server(Self)) GE (Ordering(Self)) // to refresh grid If (not(Found)) Begin If (pbDescendingIndexInUse(Self) = True or pbReverseOrdering(Self) = True) Begin Send Find to (Server(Self)) FIRST_RECORD (Ordering(Self)) End Else If (pbDescendingIndexInUse(Self) = False or pbReverseOrdering(Self) = False) Begin Send Find to (Server(Self)) LAST_RECORD (Ordering(Self)) End End If (not(Found) and IsComObjectCreated(Self)) Begin Send ResetGrid End End_Procedure Procedure Request_Delete Forward Send Request_Delete // Needed to ensure list of remaining records displayed correctly Send RefreshGrid End_Procedure // If you quickly double-right-click, or quickly click around a cCJGrid // (using a combination of middle-clicks, right-clicks and left-clicks), the application can crash. // This fixes that little problem. Procedure OnComRowRClick Variant llRow Variant llItem Boolean bProcessing Get pbRightClickProcessing to bProcessing If (not(bProcessing)) Begin Set pbRightClickProcessing to True Forward Send OnComRowRClick llRow llItem Set pbRightClickProcessing to False End End_Procedure End_Class