//**************************************************************************** // $Module type: Class // $Module name: cRDCSpinForm // $Author : Nils G. Svedmyr, RDC Tools International // Created : 2018-11-04 @ 12:34 // // Description : // // $Rev History: // 2018-11-04 Module header created // 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 Windows.pkg Use Dfspnfrm.pkg Class cSpinFormIdleHandler is a cIdleHandler Procedure Construct_Object Forward Send Construct_Object End_Procedure Procedure OnIdle Delegate Send DoUpdate End_Procedure End_Class Class cRDCSpinForm is a SpinForm Procedure Construct_Object Forward Send Construct_Object { MethodType=Property InitialValue=False } { Category=Appearance } Property Boolean pbAutoEnable False { Visibility=Private } Property Boolean pbEnabled True Property Handle phoIdleHandler (Create(Self, RefClass(cSpinFormIdleHandler))) Set Label_Justification_mode to JMode_Right Set Label_Col_Offset to 2 Set Label_Row_Offset to 0 End_Procedure Procedure End_Construct_Object String sTooltip sStatus_Help Forward Send End_Construct_Object #IF (Required_FMAC_Version > 15) Get psToolTip to sTooltip Get Status_Help to sStatus_Help If (sTooltip = "" and sStatus_Help <> "") Begin Set psToolTip to sStatus_Help End #ENDIF Set pbEnabled of (phoIdleHandler(Self)) to (pbAutoEnable(Self)) End_Procedure { Visibility=Private } Procedure DoUpdate If (pbAutoEnable(Self) = False) Begin Procedure_Return End Set Enabled_State to (IsEnabled(Self)) End_Procedure { MethodType=Event } Function IsEnabled Returns Boolean Boolean bEnabled Get pbEnabled to bEnabled Function_Return bEnabled End_Function // Enable the idle handler timer when the object is activated Procedure Activating Forward Send Activating Set pbEnabled of (phoIdleHandler(Self)) to True End_Procedure // Disable the idle handler when the object is deactivated Procedure Deactivating Set pbEnabled of (phoIdleHandler(Self)) to False Forward Send Deactivating End_Procedure // For some reason spinforms doesn't change the background color // when disabled - only the frame around it changes to "none". // This makes it hard to see that the object is unavailable. // This augmentation changes the background color to "gray", // when disabled. // Procedure Set Enabled_State Integer bState // Forward Set Enabled_State to bState // If (bState = False) Begin // Set Color to clBtnFace // End // Else Begin // Set Color to clWindow // End // End_Procedure End_Class