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

/*
	Commuter module for REACT_STATE (Reactor State) window
	
	10/8/2009 - John C. Henry, J.C. Henry & Co., Inc.
*/

DECLARE SUBROUTINE Set_Property, ErrMsg, obj_AppWindow

DECLARE FUNCTION Get_Property, Send_Message, Start_Window

$INSERT APPCOLORS
$INSERT REACT_STATE_EQUATES


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

EQU COL$RI_NO			TO 1
EQU COL$RI_TYPE			TO 2
EQU COL$RI_DESC			TO 3
EQU COL$RI_SERIAL_NO	TO 4
EQU COL$RI_INST_DTM		TO 5
EQU COL$RI_RL_NO		TO 6


ErrTitle = 'Error in REACT_STATE commuter module'
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[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
		
	CASE EntID = @WINDOW:'.CURR_RI_TYPE' AND Event = 'DBLCLK'	; GOSUB ReactItemDC
	
	CASE 1
		
		ErrorMsg = 'Unknown Parameters ':EntID:' - ':Event:' passed to commuter'
		ErrMsg('Application Message':@SVM:ErrorMsg)
		
END CASE

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

RETURN Result



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

obj_Appwindow('Create',@WINDOW)

RETURN


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


RETURN



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

*Send_Event(@WINDOW,'PAGE',1)

GOTO Refresh

RETURN

* * * * * * *
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,LS2_GREEN$)
			NEXT N
		END
	NEXT I
NEXT I

RETURN


* * * * * * *
ReactItemDC:
* * * * * * *

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

CurrList = Get_Property(EntID,'LIST')

BEGIN CASE
	CASE CurrCol = COL$RI_NO
		RINo = CurrList<CurrRow,COL$RI_NO>
		IF RINo NE '' THEN
			obj_AppWindow('ViewRelated','REACT_ITEM':@RM:RINo)
		END
	
	CASE CurrCol = COL$RI_RL_NO
		RLNo = CurrList<CurrRow,COL$RI_RL_NO>
		IF RLNo NE '' THEN
			Dummy = Start_Window( 'REACTOR_LOG', @WINDOW, RLNo:'*CENTER', '', '' )
		END
		
END CASE

RETURN


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



RETURN




