//**************************************************************************** // $Module type: CLASS // $Module name: cSyncTableCheckboxGrid // $Author : Nils G. Svedmyr // Created : 2001-07-24 @ 15:41 // // Description // // $Rev History // 2001-07-24 Module header created //**************************************************************************** Use cCheckboxColumnGrid.pkg //Use cTooltip.pkg Use cRDSWinToolTip.pkg Open SncSys Open SncTable Open SncSchem Register_Object oToolbar Register_Procedure Set phoCopy Handle ho Register_Procedure Set phoPaste Handle ho Register_Procedure Set phoCut Handle ho Class cSyncTableCheckboxGrid Is A cCheckboxColumnGrid Import_Class_Protocol cRDSWinToolTip Procedure Construct_Object Integer iColor Forward Send Construct_Object Property Handle phoDD 0 Property Boolean pbAllowAutoDelete SncSys.AllowAutoDelete Property Boolean pbAllowTblChange SncSys.AllowTblChange Property Boolean pbSynchSetup False Send Define_cRDSWinToolTip Set pbClassEnabledHandleType To False // True=Default Set pbClassDisabledHandleType To True // True=Default Set pbClassEntryStateHandleType To True // True=Default // Property Handle Private.phoToolTip 0 // Object oTooltip Is A cTooltip // Set Private.phoToolTip To (Self) // End_Object // oTooltip Get ReadDWord Of ghoApplication "Preferences" "CurrentRowColor" 0 To iColor If Not iColor Move clAqua To iColor Set CurrentRowColor To iColor Get ReadDWord Of ghoApplication "Preferences" "CurrentCellColor" 0 To iColor If Not iColor Move clYellow To iColor Set CurrentCellColor To iColor Set Highlight_Row_State To True Set piCheckBoxColumn To 0 Set piCheckBoxColumn2 To 3 Set Horz_Scroll_Bar_Visible_State To False // On_Key Key_Tab Send Switch Set Entry_msg to DoDisableToolbarButtons Set Exit_msg to DoEnableToolbarButtons // If (pbSynchSetup(Self)) ; // Set Status_Help Item 0 To "Select the items that should be belong to a Collection Name." // Else Begin // If (pbAllowTblChange(Self)) Set Status_Help Item 0 To "Select items to be connected" // Else Set Status_Help Item 0 To "You are not allowed to change the selections" // End // Else Begin // Set Status_Help Item 1 To "An optional name to sort records in the Collection grid and in the Connect Engine grid. Can only be set on the 'Database Tables' tab-page." // Set Status_Help Item 2 To "These are the tables that will be connected." // If (piCheckBoxColumn2(Self)) Begin // If (pbSynchSetup(Self)) ; // Set Status_Help Item 3 To "Auto Delete can only be changed on the Index/Sorting tab-page." // Else Begin // If (pbAllowAutoDelete(Self)) Set Status_Help Item 3 To "Select to delete records in the Destination table that has been deleted in the Source table" // Else Set Status_Help Item 3 To "You are not allowed to change the Auto Delete state" // End // Else Begin // End // If (piCheckBoxColumn2(Self)) Begin End_Procedure // Construct_Object // Procedure End_Construct_Object // Handle ho // String sHelp // Boolean bVisible bPopup // Forward Send End_Construct_Object // Get Private.phoToolTip To ho // Get Visible_State To bVisible // If (ho > 0 And bVisible = True) Begin // Delegate Get Popup_State To bPopup // If (bPopup = False) Send Activate Of ho // End // If (ho > 0 And bVisible = True) Begin // End_Procedure // End_Construct_Object Procedure DoFillGrid Handle hoDD Integer iCols iRecid iRecnum String sText sSort Get Line_Size To iCols Set Dynamic_Update_State To False Send Delete_Data Move SncTable.Recnum To iRecnum Clear SncTable Constraint_Set Self Constrain SncTable.Hide eq 0 Constrained_Find First SncTable by Index.2 While (Found) Move (Trim(SncTable.Text)) To sText Move (Trim(SncTable.SortField)) To sSort If (sText <> "") Begin Move SncTable.Recid To iRecid If (iCols > 0) Begin Send DoAddCheckBoxItem Set Aux_Value Item (Item_Count(Self) - 1) To iRecid If (pbSynchSetup(Self)) ; Set Aux_Value Item (Item_Count(Self) - 1) To iRecid // Set Status_Help item (Item_Count(Self) - 1) To "Select the items that should be belong to a Collection Name." Else Begin // If (pbAllowTblChange(Self)) Set Status_Help (Item_Count(Self) - 1) To "Select items to be connected" // Else Set Status_Help (Item_Count(Self) - 1) To "You are not allowed to change the selections" Set Shadow_State Item (Item_Count(Self) - 1) To (Not(pbAllowTblChange(Self))) End // Else Begin End // If (iCols > 0) Begin If (iCols > 1) Begin Send DoAddTextItem sSort Set Shadow_State Item (Item_Count(Self) - 1) To False // Set Status_Help (Item_Count(Self) - 1) To "An optional name to sort records in the Collection grid and in the Connect Engine grid. Can only be set on the 'Database Tables' tab-page." Send DoAddTextItem sText If Not (pbSynchSetup(Self)) ; Set Shadow_State Item (Item_Count(Self) - 1) To False // Set Status_Help (Item_Count(Self) - 1) To "These are the tables that will be connected." End If (piCheckBoxColumn2(Self)) Begin Send DoAddCheckBoxItem If (pbSynchSetup(Self)) Begin Set Shadow_State item (Item_Count(Self) - 1) To True // Set Status_Help item (Item_Count(Self) - 1) To "Auto Delete can only be changed on the Index/Sorting tab-page." End // If (pbSynchSetup(Self)) Begin Else Begin // If (pbAllowAutoDelete(Self)) Set Status_Help (Item_Count(Self) - 1) To "Select to delete records in the Destination table that has been deleted in the Source table" // Else Set Status_Help item (Item_Count(Self) - 1) to "You are not allowed to change the Auto Delete state" Set Shadow_State item (Item_Count(Self) - 1) To (Not(pbAllowAutoDelete(Self))) End // If Not SncSys.AllowAutoDelete Begin End // If (piCheckBoxColumn2(Self)) Begin End // If (sText <> "") Begin Constrained_Find Next Loop // While (Found) Clear SncTable If iRecnum Begin Move iRecnum To SncTable.Recnum Find eq SncTable by Recnum End // If iRecnum Begin Set Dynamic_Update_State To True End_Procedure // DoFillGrid Procedure DoDisplayScheme String sSchemeName Integer iRow iItem_Count iLength iRows iCols iPos iRecnum iCheckboxColumn2 Boolean bState bHide String sTables sDeletes sHides Set Dynamic_Update_State To False Get Item_Count To iItem_Count Get Line_Size To iCols Get piCheckBoxColumn2 To iCheckboxColumn2 Move SncTable.Recnum To iRecnum Clear SncTable Constraint_Set (Self + 1) Constrained_Find First SncTable by Index.1 Move "" to sHides While (Found) Move (sHides + String(SncTable.Hide)) To sHides Constrained_Find Next End Clear SncTable If iRecnum Begin Move iRecnum To SncTable.Recnum Find eq SncTable by Recnum End // If iRecnum Begin Clear SncSchem Move sSchemeName To SncSchem.Name Find Eq SncSchem by index.1 Move (Trim(SncSchem.Tables)) To sTables Move (Trim(SncSchem.Deletes)) To sDeletes Move (iItem_Count / iCols) To iRows If (sHides Contains "1") Begin For iRow From 1 To iRows Move (Pos("1", sHides)) To iPos If iPos Begin Move (Overstrike("|", sHides, iPos)) To sHides Move (Overstrike("|", sTables, iPos)) To sTables Move (Overstrike("|", sDeletes, iPos)) To sDeletes End // If iPos Begin Loop // For iCount from 1 to iHide Move (Replaces("|", sTables, "")) To sTables Move (Replaces("|", sDeletes, "")) To sDeletes End // If (sHides Contains "1") Begin For iRow From 0 To (iRows - 1) Move (Mid(sTables, 1, (iRow + 1))) To bState Set Select_State item (iRow * iCols) To bState If iCheckboxColumn2 Begin Move (Mid(sDeletes, 1, iRow)) To bState Set Select_State item (iRow * iCols + iCheckboxColumn2) To bState End // If iCheckboxColumn2 Begin Loop // For iRow From 1 to iLength Clear SncSchem Set Dynamic_Update_State To True End_Procedure // DoDisplayScheme Function SelectedItems Returns String Integer iItem iItem_Count iCols String sSelected sSncTables Move "" To sSncTables Get Item_Count To iItem_Count Get Line_Size To iCols For iItem From 0 To (iItem_Count - 1) Get Select_State item iItem To sSelected Move (Append(sSncTables, sSelected)) To sSncTables Add (iCols -1) To iItem Loop Move (Trim(sSncTables)) To sSncTables Function_Return sSncTables End_Function // SelectedItems Function SelectedDeletes Returns String Integer iItem iItem_Count iCols iCheckboxColumn2 String sSelected sDeletes Get Item_Count To iItem_Count Get Line_Size To iCols Get piCheckBoxColumn2 To iCheckboxColumn2 For iItem From 0 To (iItem_Count - 1) Get Select_State item (iItem + iCheckboxColumn2) To sSelected Move (Append(sDeletes, sSelected)) To sDeletes Add (iCols -1) To iItem Loop Function_Return sDeletes End_Function // SelectedItems Function NumberSelectedItems Returns Integer Integer iItem iItem_Count iCols iRetval Boolean bSelected Get Item_Count To iItem_Count Get Line_Size To iCols For iItem From 0 To (iItem_Count - 1) Get Select_State item iItem To bSelected If bSelected Increment iRetval Add (iCols -1) To iItem Loop Function_Return iRetval End_Function // NumberSelectedItems // Auto Send by End_construct_object Procedure DoInitGrid Send DoFillGrid Send DoDisplayScheme SncSys.Default_Scheme End_Procedure // Toggles all files on, off or invert selections. // bState = 1 - Select all // = 0 - Deselect all // = -1 - Invert select state Procedure DoToggleAll Integer iState Integer iItem_Count iCols iItem iCheckboxColumn2 Boolean bState If (iState = 1) Send StartWorkingMessage "Selecting All" If (iState = 0) Send StartWorkingMessage "Deselecting All" If (iState = -1) Send StartWorkingMessage "Inverting Selection" Set Dynamic_Update_State To False Get Item_Count To iItem_Count Get Line_Size To iCols Get piCheckBoxColumn2 To iCheckboxColumn2 For iItem From 0 To (iItem_Count - 1) Get Select_State item iItem To bState If (iState = - 1) Move (Not(bState)) To bState Else Move iState To bState Set Select_State item iItem To bState If (iCheckboxColumn2 and Not(bState)) Begin Get Select_State item (iItem + iCheckboxColumn2) To bState If bState Set Select_State Item (iItem + iCheckboxColumn2) To False End // If (iCheckboxColumn2 and Not(bState)) Begin Add (iCols -1) To iItem End // While (Found) Set Dynamic_Update_State To True Send StopWorkingMessage End_Procedure // DoToggleAllFiles Procedure Select_Toggling Integer iItem Integer bState Integer iCheckboxColumn2 iCol iCrnt iFirstCol iLastCol iFirstState iLastState Boolean bAllowAutoDelete bSynchSetup Get Current_Col To iCol Get Current_Item To iItem Get piCheckBoxColumn2 To iCheckboxColumn2 Get pbAllowAutoDelete To bAllowAutoDelete Get pbSynchSetup To bSynchSetup Get Select_State Item (iItem -iCol) To iFirstState If (iCol = 1) Move (iItem - 1) To iItem If (iCol = 2) Move (iItem - 2) To iItem If bSynchSetup ; If (iCol = 3) Move (iItem - 3) To iItem // Do not toggle last column (auto delete) if first column is // not selected and not bSynchSetup: If (iCol = iCheckboxColumn2 And Not(iFirstState)) Procedure_Return Forward Send Select_Toggling iItem bState // If first column is deselected and last column (auto delete) was // selected, deselect the last column as well: If (iCheckboxColumn2 And iCol < iCheckboxColumn2) Begin Get Select_State Item (iItem + iCheckboxColumn2) To iLastState If iLastState Set Select_State Item (iItem + iCheckboxColumn2) To False End // If (iCheckboxColumn2 And iCol < iCheckboxColumn2) Begin End_Procedure // Select_Toggling Procedure DoEnableToolbarButtons Handle ho Move (oToolBar(Self)) To ho If ho Begin Get phoCut To ho If ho Set pbEnabled Of ho To True Get phoCopy To ho If ho Set pbEnabled Of ho To True Get phoPaste To ho If ho Set pbEnabled Of ho To True End // If ho Begin End_Procedure // DoEnableToolbarButtons Procedure DoDisableToolbarButtons Handle ho Boolean bState Move (oToolBar(Self)) To ho If ho Begin Get phoCut To ho If ho Set pbEnabled Of ho To False Get phoCopy To ho If ho Set pbEnabled Of ho To False Get phoPaste To ho If ho Set pbEnabled Of ho To False End // If ho Begin End_Procedure // DoDisableToolbarButtons Procedure Set pbHidden Boolean bMode Handle ho Set Visible_State To (Not(bMode)) Set Enabled_State To (Not(bMode)) Set Focus_Mode To (If(bMode = True, NonFocusable, Focusable)) End_Procedure // Set pbHidden Function pbHidden Returns Boolean Function_Return (Visible_State(Self)) End_Function // pbHidden // Procedure Set pbToolTips Boolean bState // Handle ho // Get Private.phoToolTip To ho // If ho Begin // If (bState = False) Send DeActivate Of ho // Else Send Activate Of ho // End // If ho Begin // End_Procedure // Set pbToolTips // Procedure Page Integer iFlag // Handle ho hWnd // String sHelp // Boolean bVisible bPopup // Forward Send Page iFlag // Get Private.phoToolTip To ho // Get Visible_State To bVisible // If (ho And bVisible) Begin // Get Status_Help Item 0 To sHelp // Set psTooltip Of ho To (ToAnsi(sHelp)) // Get Window_Handle To hWnd // If (iFlag And ho > 0 And hWnd > 0) Send AddTool Of ho hWnd // End // If (ho And bVisible) Begin // End_Procedure // Page // Procedure Destroy // Send DestroyToolTip // Forward Send Destroy // End_Procedure // Destroy // Procedure DestroyToolTip // Handle ho // Get Private.phoToolTip To ho // If ho Begin // Send Destroy Of ho // Set Private.phoToolTip To 0 // End // If ho Begin // End_Procedure // DestroyToolTip End_Class // cSyncTableCheckboxGrid