COMPILE FUNCTION Comm_React_Comp(EntID,Event,Parm1,Parm2,Parm3,Parm4,Parm5)

/*
	Commuter module for REACT_COMP (Reactor Components) window
	
	11/01/2009 - John C. Henry, J.C. Henry & Co., Inc.
*/


DECLARE SUBROUTINE Set_Property, End_Dialog, Send_Event, Set_Status, ErrMsg, obj_Appwindow

DECLARE FUNCTION Get_Property, Get_Status, obj_Appwindow, Send_Message, NextKey, Popup


$INSERT APPCOLORS
$INSERT LSL_USERS_EQU


EQU CRLF$	TO \0D0A\
EQU TAB$	TO \09\


ErrTitle = 'Error in CleanInsp'
ErrorMsg = ''

Result = ''

BEGIN CASE
	CASE EntID = @WINDOW
		BEGIN CASE
			CASE Event = 'CLEAR'			; GOSUB Clear
			CASE Event = 'CREATE' 			; GOSUB Create
			CASE Event = 'CLOSE'			; GOSUB Close
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event = 'VSCROLL'			; GOSUB VScroll
			CASE Event = 'PAGE'				; GOSUB Page
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	
	CASE EntID = @WINDOW:'.LU_COMP_NO' AND Event = 'CLICK'	 		; GOSUB LUCompNo
	CASE EntID = @WINDOW:'.LU_CLASS' AND Event = 'CLICK'			; GOSUB LUClass
	CASE EntID = @WINDOW:'.LU_PARENT' AND Event = 'CLICK'			; GOSUB LUParent
	CASE EntID = @WINDOW:'.NEW_BUTTON' AND Event = 'CLICK'			; GOSUB New
	CASE EntID = @WINDOW:'.VIEW_PARENT' AND Event = 'CLICK'			; GOSUB ViewParent
	
	CASE EntID = @WINDOW:'.SUB_COMP'
		BEGIN CASE 
			CASE Event = 'DBLCLK'									; GOSUB SubCompDC
		END CASE
	
	
	CASE 1
		
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg(ErrorMsg)
		
END CASE

IF ErrorMsg NE '' THEN
	ErrMsg(ErrTitle:@SVM:ErrorMsg)
END

RETURN Result



* * * * * * *
Create:
* * * * * * *

obj_Appwindow('Create',@WINDOW)


GOSUB Refresh

RETURN


* * * * * * *
New:
* * * * * * *

CompNo = Get_Property(@WINDOW,'.COMP_NO')

IF CompNo = '' THEN
	NextCompNo = NextKey('REACT_COMP')
	obj_Appwindow('LoadFormKeys',@WINDOW:@RM:NextCompNo)
END

RETURN


* * * * * * *
Page:
* * * * * * *

Page = Get_Property(@WINDOW:'.MAIN_TAB', 'VALUE')

Set_Property(@WINDOW,'VPOSITION', Page)

RETURN


* * * * * * *
VScroll:
* * * * * * *

Page = Parm1

Set_Property(@WINDOW:'.MAIN_TAB','VALUE', Page)

RETURN


* * * * * * *
Clear:
* * * * * * *


GOSUB Refresh

RETURN



* * * * * * *
Read:
* * * * * * *

obj_AppWindow('Read')


* * * * * * *
Refresh:
* * * * * * *


* QBF buttons

Ctrls  = @WINDOW:'.QBF_FIRST_FIX':@RM		; Props  = 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_PREV_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_ABS_FIX':@RM			; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_NEXT_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_LAST_FIX':@RM		; Props := 'ENABLED':@RM
Ctrls := @WINDOW:'.QBF_STOP_FIX'			; Props := 'ENABLED'

IF Get_Property(@WINDOW,'QBFLIST') = '' THEN
	Vals = 0:@RM:0:@RM:0:@RM:0:@RM:0:@RM:0
END ELSE
	Vals = 1:@RM:1:@RM:1:@RM:1:@RM:1:@RM:1
END

Set_Property(Ctrls,Props,Vals)



* Turn edit table symbolic column backgrounds to green *
ETSymbolics = Get_Property(@WINDOW,'@ET_SYMBOLICS')		;* Loaded during 'Create' in obj_Appwindow

ETCtrls	= ETSymbolics<1>
ETCols	= ETSymbolics<2>

FOR I = 1 TO COUNT(ETCtrls,@VM) + (ETCtrls NE '')
	ETCtrl	= ETCtrls<1,I>
	ETList = Get_Property(ETCtrl,'LIST')
	FOR Line = 1 TO COUNT(ETList,@FM) + (ETList NE '')
		IF ETList<Line,1> NE '' THEN
			FOR N = 1 TO COUNT(ETCols<1,I>,@SVM) + (ETCols<1,I> NE '')
				stat = Send_Message(ETCtrl,'COLOR_BY_POS',ETCols<1,I,N>,Line,GREEN$)
			NEXT N
		END
	NEXT I
NEXT I

RETURN


* * * * * *
Close:
* * * * * * 


RETURN



* * * * * * 
Write:
* * * * * *

obj_AppWindow('PreWrite')

Result = 1


RETURN


* * * * * *
LUClass:
* * * * * *

CompClass = Popup(@WINDOW,'','REACT_COMP_CLASS')

IF CompClass NE '' THEN
	obj_Appwindow('LUValReturn',CompClass:@RM:'CLASS')
END


RETURN


* * * * * *
LUCompNo:
* * * * * *

CompNos = Popup(@WINDOW,'','REACT_COMP')

IF INDEX(CompNos,@VM,1) THEN
	Set_Property(@WINDOW,'QBFLIST',CompNos)
END ELSE
	obj_AppWindow('LoadFormKeys',@WINDOW:@RM:CompNos)
END

RETURN



* * * * * *
LUParent:
* * * * * *

CompNo = Popup(@WINDOW,'','REACT_COMP')

IF CompNo NE '' THEN
	obj_Appwindow('LUValReturn',CompNo:@RM:'PARENT')
END


RETURN


* * * * * * * 
ViewParent:
* * * * * * *

CompNo = Get_Property(@WINDOW:'.PARENT','DEFPROP')

Send_Event(@WINDOW,'CLEAR')

obj_Appwindow('LoadFormKeys',@WINDOW:@RM:CompNo)

RETURN



* * * * * * *
SubCompDC:
* * * * * * *

CtrlEntID = @WINDOW:'.SUB_COMP'

CurrPos = Get_Property(CtrlEntID,'SELPOS')
CurrCol = CurrPos<1>
CurrRow = CurrPos<2>

CompNo = Get_Property(CtrlEntID,'CELLPOS',1:@FM:CurrRow)	;* Comp No is in column 1

IF CompNo NE '' THEN
	Send_Event(@WINDOW,'CLEAR')
	obj_Appwindow('LoadFormKeys',@WINDOW:@RM:CompNo)
END

RETURN





