Function DBW_MSC_CONFIG_EVENTS(CtrlEntId, Event, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15)
/******************************************************************************************************** 

    This program is proprietary and is not to be used by or disclosed to others, nor is it to
    be copied without written permission from SRP Computer Solutions, Inc.

    Name        :	MSC Config Events

    Description :
    
	Tags		:	[SRP]

    Parameters  :

    History (Date, Initials, Notes)
        02/06/10    fjt     Initial development

********************************************************************************************************/

$insert SRP_APP_INSERTS
$insert SRP_EVENT_SETUP

Equ Icon$   	to "bmps/help_msc.bmp"
Equ Schedule$   to "WO_MASTER_SCHEDULER.OLE_SCHEDULE"
Equ W$			to @Window:"."

Declare subroutine SRP_Redirect_OLE_Events, SRP_Show_Window
Declare function SVC_Option_Button

Begin Case

	Case Event EQ "CLICK"
		Begin Case
			Case Control EQ "PUB_CANCEL"		; GoSub CLICK.PUB_CANCEL
			Case Control EQ "PUB_DONE"			; GoSub CLICK.PUB_DONE
		End Case

	Case Event EQ "OnOptionClick"
		Control = Field(Param1, ".", 2)
		GoSub Show_Help

    Case Control EQ Window
        Begin Case
        	Case Event EQ "CLOSE"				; Gosub Window.CLOSE
            Case Event EQ "CREATE"              ; GoSub Window.CREATE
            * Case Event EQ "READ"            	; GoSub Window.READ
            * Case Event EQ "WRITE"				; GoSub Window.WRITE
        End Case

End Case

If Assigned(Ans) else Ans = 1
Return Ans


!----- EVENTS -------------------------------------------------------------------------------------------


CLICK.PUB_CANCEL:
	Send_Event(@Window, "CLOSE")
	Ans = 0
return


CLICK.PUB_DONE:
	GoSub Write_Record
	Send_Event(@Window, "CLOSE")
	Ans = 0
return


Window.CLOSE:
return


Window.CREATE:
	rv = SVC_Option_Button("Add", @Window, "EDL_ENTITY_MIN_SIZE", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_INTERVAL", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_INTERVAL_SIZE", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_HOUR_INCREMENT", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_TBH_FACE", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_TBM_FACE", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_EHN_FACE", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_EHD_FACE", Icon$)
	rv = SVC_Option_Button("Add", @Window, "EDL_CD_FACE", Icon$)
	
	GoSub Read_Record
	
	SRP_Redirect_OLE_Events()
	SRP_Show_Window(@Window, "", "C", "C", 1)
return


!----- INTERNAL -----------------------------------------------------------------------------------------


Read_Record:
	Rec = Xlate("CONFIG", "MSC_CONFIGURATION", "", "X")
	
	Set_Property(W$:"EDL_ENTITY_MIN_SIZE", "INVALUE", Rec<01>)
	Set_Property(W$:"EDL_INTERVAL",		   "INVALUE", Rec<02>)
	Set_Property(W$:"EDL_INTERVAL_SIZE",   "INVALUE", Rec<03>)
	Set_Property(W$:"EDL_HOUR_INCREMENT",  "INVALUE", Rec<04>)
	Set_Property(W$:"EDL_TBH_FACE",		   "DEFPROP", Rec<05,1>)
	Set_Property(W$:"EDL_TBH_SIZE",		   "INVALUE", Rec<05,2>)
	Set_Property(W$:"EDL_TBM_FACE",		   "DEFPROP", Rec<06,1>)
	Set_Property(W$:"EDL_TBM_SIZE",		   "INVALUE", Rec<06,2>)
	Set_Property(W$:"EDL_EHN_FACE",		   "DEFPROP", Rec<07,1>)
	Set_Property(W$:"EDL_EHN_SIZE",		   "INVALUE", Rec<07,2>)
	Set_Property(W$:"EDL_EHD_FACE",		   "DEFPROP", Rec<08,1>)
	Set_Property(W$:"EDL_EHD_SIZE",		   "INVALUE", Rec<08,2>)
	Set_Property(W$:"EDL_CD_FACE",		   "DEFPROP", Rec<09,1>)
	Set_Property(W$:"EDL_CD_SIZE",		   "INVALUE", Rec<09,2>)
	Set_Property(W$:"EDL_HISTORICAL",	   "INVALUE", Rec<10>)
return


Show_Help:
	Ctrl = Param1
	Text = ""
	
	Begin Case
		Case Control EQ "EDL_ENTITY_MIN_SIZE"	; Text = "Height of each reactor row, measured in pixels"
		Case Control EQ "EDL_INTERVAL"			; Text = "The number of minutes per interval"
		Case Control EQ "EDL_INTERVAL_SIZE"		; Text = "The number pixels per interval; space (width) for each time increment"
		Case Control EQ "EDL_HOUR_INCREMENT"	; Text = "Hour display increment (1-12)"
		Case Control EQ "EDL_TBH_FACE"			; Text = "The font used to display hours in the time bar"
		Case Control EQ "EDL_TBM_FACE"			; Text = "The font used to display minutes in the time bar"
		Case Control EQ "EDL_EHN_FACE"			; Text = "The font used to display the entity name in it's column header"
		Case Control EQ "EDL_EHD_FACE"			; Text = "The font used to display the entity description beneath it's name in the column header"
		Case Control EQ "EDL_CD_FACE"			; Text = "The font used to display the date on the very top line"
	End Case

	If Text GT "" then

		Config = ""
		Config<1> = Text
		Config<2> = "Help"  ;// title
		Config<3> = 1		;// info icon
		Config<4> = 0		;// no delay, close on user
	
		SubClasser = @Window:".OLE_SUBCLASS"
		Handle = Get_Property(Ctrl, "HANDLE")
		rv = Send_Message(SubClasser, "OLE.Subclass", Handle, Ctrl)
	
		CtrlId = Ctrl
		Convert "." to ";" in CtrlId
		rv = Send_Message(SubClasser, "OLE.ShowBalloonTooltip", CtrlId, Config)
		
	end
return


Write_Record:
	Open "CONFIG" to hTable then
		Rec = ""
		Rec<01>   = Get_Property(W$:"EDL_ENTITY_MIN_SIZE", "INVALUE")
		Rec<02>   = Get_Property(W$:"EDL_INTERVAL",		  "INVALUE")
		Rec<03>   = Get_Property(W$:"EDL_INTERVAL_SIZE",  "INVALUE")
		Rec<04>   = Get_Property(W$:"EDL_HOUR_INCREMENT", "INVALUE")
		Rec<05,1> = Get_Property(W$:"EDL_TBH_FACE",		  "DEFPROP")
		Rec<05,2> = Get_Property(W$:"EDL_TBH_SIZE",		  "INVALUE")
		Rec<06,1> = Get_Property(W$:"EDL_TBM_FACE",		  "DEFPROP")
		Rec<06,2> = Get_Property(W$:"EDL_TBM_SIZE",		  "INVALUE")
		Rec<07,1> = Get_Property(W$:"EDL_EHN_FACE",		  "DEFPROP")
		Rec<07,2> = Get_Property(W$:"EDL_EHN_SIZE",		  "INVALUE")
		Rec<08,1> = Get_Property(W$:"EDL_EHD_FACE",		  "DEFPROP")
		Rec<08,2> = Get_Property(W$:"EDL_EHD_SIZE",		  "INVALUE")
		Rec<09,1> = Get_Property(W$:"EDL_CD_FACE",		  "DEFPROP")
		Rec<09,2> = Get_Property(W$:"EDL_CD_SIZE",		  "INVALUE")
		Rec<10>   = Get_Property(W$:"EDL_HISTORICAL",	  "INVALUE")
		
		Write Rec to hTable, "MSC_CONFIGURATION" then
			Msg(@Window, "", "OK", "", "MSC Config" :@FM: "Restart the scheduler for changes to be applied.")
		end
	end
return
