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

/*
	Commuter module for TOOL_Stage (Tool Stage) window
	
	10/17/2012 - John C. Henry, J.C. Henry & Co., Inc.
	*/

DECLARE SUBROUTINE Set_Property,  Set_Status, ErrMsg, Set_Property, obj_AppWindow, Send_Event
DECLARE FUNCTION Get_Property, Get_Status, Popup, Send_Message, Msg, Start_Window

$INSERT POPUP_EQUATES
$INSERT MSG_EQUATES
$INSERT APPCOLORS
$INSERT TOOL_CLASS_EQUATES
$INSERT TOOL_PROP_EQUATES
$INSERT TOOL_EQUATES

EQU CRLF$	TO \0D0A\


ErrTitle = 'Error in Comm_Tool_Stage'
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 = 'READ'				; GOSUB Read
			CASE Event = 'WRITE'			; GOSUB Write
			CASE Event[1,3] = 'QBF'			; GOSUB Refresh
		END CASE
	
	
	CASE EntID = @WINDOW:'.LU_TOOL_CLASS' AND		Event = 'CLICK'	; GOSUB LUToolClass
	CASE EntID = @WINDOW:'.LU_TOOL_TYPE' AND		Event = 'CLICK'	; GOSUB LUToolType
	
	
	CASE EntID = @WINDOW:'.TOOL_PROP_KEY'
		BEGIN CASE
			CASE Event = 'DBLCLK'			; GOSUB PropertyDC
		
		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


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

GOSUB Refresh

RETURN


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

GOTO Close

RETURN

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


GOTO Refresh

RETURN

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

obj_Appwindow('DetailReturn')

RETURN


* * * * * * *
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 Line
	
NEXT I



RETURN

* * * * * * *
PropertyDC:
* * * * * * *


RETURN



* * * * * * *
LUToolClass:
* * * * * * *

ClassCd = Popup(@WINDOW,'','TOOL_CLASS')

IF ClassCD NE '' THEN
	oaParms = @WINDOW:@RM:ClassCd
	obj_Appwindow('ViewRelated',oaParms)
END


RETURN


* * * * * * *
LUToolType:
* * * * * * *

ToolType = Popup(@WINDOW,'','TOOL_TYPE')

IF ToolType NE '' THEN
	oaParms = ToolType:@RM:@WINDOW:'.TOOL_TYPE'
	obj_Appwindow('LUValReturn',oaParms)
END



RETURN
