
DECLARE CONSTANT n_InstSelHeight 	AS  QUANTITY	32
DECLARE CONSTANT n_HeaderHeight 	AS  QUANTITY	30
DECLARE CONSTANT n_ExtHeaderHeight 	AS  QUANTITY	76
DECLARE CONSTANT n_MainOEHeight 	AS  QUANTITY	150
DECLARE CONSTANT n_AdvanceOptHeight  AS  QUANTITY	72
DECLARE CONSTANT n_RecentTranscHeight  AS  QUANTITY	147
DECLARE CONSTANT n_SeparatorHeight  AS  QUANTITY	18
DECLARE CONSTANT n_DebtHeight  		AS  QUANTITY	23

DECLARE CONSTANT n_HeaderRow  			AS  QUANTITY	0
DECLARE CONSTANT n_ExtHeaderRow  		AS  QUANTITY	1
DECLARE CONSTANT n_MainOERow  			AS  QUANTITY	2
DECLARE CONSTANT n_QuoteRow  			AS  QUANTITY	3
DECLARE CONSTANT n_RFQRow  				AS  QUANTITY	4
DECLARE CONSTANT n_UDSRow  				AS  QUANTITY	5
DECLARE CONSTANT n_DeptEntry			AS  QUANTITY	6
DECLARE CONSTANT n_AdvanceOptRow  		AS  QUANTITY	7
DECLARE CONSTANT n_RecentTransactRow  	AS  QUANTITY	8

DECLARE VARIABLE n_RecentTransPane  AS QUANTITY 
DECLARE VARIABLE n_AdvanceOptPane	AS QUANTITY
DECLARE VARIABLE n_ExtHeaderPane		AS QUANTITY
DECLARE VARIABLE n_ExtMore				AS QUANTITY
DECLARE VARIABLE n_DebtMode				AS QUANTITY
DECLARE VARIABLE n_OrderMode			AS QUANTITY
DECLARE VARIABLE n_ExtMoreShrinked		AS QUANTITY

DECLARE VARIABLE n_ExtHeaderPanePerf    AS QUANTITY
DECLARE VARIABLE n_AmendWnd    		AS QUANTITY

#expand buttons
DECLARE CONSTANT n_BtnAdvancedOpt  		AS  QUANTITY	40000
DECLARE CONSTANT n_BtnRecentTransact  	AS  QUANTITY	50000
DECLARE CONSTANT n_BtnMore			  	AS  QUANTITY	60000
DECLARE CONSTANT n_BtnDashboard  		AS  QUANTITY	30013

#Entry type radio buttons
DECLARE CONSTANT n_RadioOrder 	AS  QUANTITY	30005
DECLARE CONSTANT n_RadioQuote 	AS  QUANTITY	30006
DECLARE CONSTANT n_RadioRFQ 	AS  QUANTITY	30007
DECLARE CONSTANT n_RadioUDS 	AS  QUANTITY	30008

DECLARE CONSTANT n_ResizerHeight  	AS  QUANTITY	18

##########################################################
PROCEDURE UpdateLayoutAndHeight DO
{
	IF ([n_AmendWnd] = 1) DO
	{
		CALL UpdateAMENDLayoutAndHeight ;
		RETURN
	}
	
	DECLARE VARIABLE 	nWndID 		AS QUANTITY
	DECLARE VARIABLE 	nWndHeight 	AS QUANTITY

	SLogLine("UpdateLayoutAndHeight");
		
	IF (IsWndTitleBarVisible(GetWndID()) = 1) THEN
	{
		[nWndHeight] := ( GetToolbarHeight() + n_InstSelHeight + n_MainOEHeight + 3);
	}
	ELSE
	{
		[nWndHeight] := ( n_InstSelHeight + n_MainOEHeight + 3);
	}	
	
	IF ( [n_ExtHeaderPane] = 0 ) THEN
	{
		ShowRow(n_ExtHeaderRow, 0);
		ShowRow(n_HeaderRow, 1);
		SetRowHeight(n_HeaderRow, n_HeaderHeight, 1);		
		
		[nWndHeight] := ([nWndHeight] + n_HeaderHeight);	
	}
	ELSE 
	{
		ShowRow(n_HeaderRow, 0);
		ShowRow(n_ExtHeaderRow, 1);
		SetRowHeight(n_ExtHeaderRow, n_ExtHeaderHeight, 1);
		
		[nWndHeight] := ([nWndHeight] + n_ExtHeaderHeight);
	}
	
	ShowRow(n_AdvanceOptRow, 1);
	IF ( [n_AdvanceOptPane] = 0 ) THEN
	{
		SetRowHeight(n_AdvanceOptRow, n_SeparatorHeight, 1);
		[nWndHeight] := ([nWndHeight] + n_SeparatorHeight);
	}
	ELSE
	{
		SetRowHeight(n_AdvanceOptRow, n_AdvanceOptHeight, 1);
		[nWndHeight] := ([nWndHeight] + n_AdvanceOptHeight);		
	}
	
	ShowRow(n_RecentTransactRow, 1);
	IF ( [n_RecentTransPane] = 0 ) THEN
	{
		SetRowHeight(n_RecentTransactRow, (n_SeparatorHeight + 5), 1);
		[nWndHeight] := ([nWndHeight] + (n_SeparatorHeight + 5));
	}
	ELSE
	{
		SetRowHeight(n_RecentTransactRow, n_RecentTranscHeight, 1);
		[nWndHeight] := ([nWndHeight] + n_RecentTranscHeight);
	}	
	
	IF ( [n_ExtMore] = 1 ) THEN
	{
		[nWndHeight] := ([nWndHeight] + 122);
	} ELSE 
	{
		[nWndHeight] := ([nWndHeight] + (n_SeparatorHeight + 1));
	}

	IF ( [n_DebtMode] = 1 ) DO		
	{
		[nWndHeight] := ([nWndHeight] + n_DebtHeight);
	}  
		
	[nWndID] := GetWndID();
	SetWndHeight([nWndID], [nWndHeight]);
}

##########################################################
PROCEDURE UpdateAMENDLayoutAndHeight DO
{	
	DECLARE VARIABLE 	nWndID 		AS QUANTITY
	DECLARE VARIABLE 	nWndHeight 	AS QUANTITY

	SLogLine("UpdateAMENDLayoutAndHeight");
		
	IF ([n_AmendWnd] = 0) DO
	{
		RETURN
	}
		
	[nWndHeight] := ( GetToolbarHeight() + n_MainOEHeight + 3);
	
	ShowRow(n_AdvanceOptRow, 1);
	IF ( [n_AdvanceOptPane] = 0 ) THEN
	{
		SetRowHeight(n_AdvanceOptRow, n_SeparatorHeight, 1);
		[nWndHeight] := ([nWndHeight] + n_SeparatorHeight);
	}
	ELSE
	{
		SetRowHeight(n_AdvanceOptRow, n_AdvanceOptHeight, 1);
		[nWndHeight] := ([nWndHeight] + n_AdvanceOptHeight);		
	}
	
	ShowRow(n_RecentTransactRow, 1);
	IF ( [n_RecentTransPane] = 0 ) THEN
	{
		SetRowHeight(n_RecentTransactRow, (n_SeparatorHeight + 5), 1);
		[nWndHeight] := ([nWndHeight] + (n_SeparatorHeight + 5));
	}
	ELSE
	{
		SetRowHeight(n_RecentTransactRow, n_RecentTranscHeight, 1);
		[nWndHeight] := ([nWndHeight] + n_RecentTranscHeight);
	}	
	
	IF ( [n_ExtMore] = 1 ) THEN
	{
		[nWndHeight] := ([nWndHeight] + 122);
	} ELSE 
	{
		[nWndHeight] := ([nWndHeight] + (n_SeparatorHeight + 1));
	}
	
	IF ( [n_DebtMode] = 1 ) DO		
	{
		[nWndHeight] := ([nWndHeight] + n_DebtHeight);
	}  
	
	[nWndID] := GetWndID();
	SetWndHeight([nWndID], [nWndHeight]);
}


##########################################################	
PROCEDURE InitLayoutForAmmend
		DECLARE PARAMETER sParam1 AS TEXT DO
{
	ShowRow(n_HeaderRow, 0);
	ShowRow(n_ExtHeaderRow, 0);
	ShowRow(n_QuoteRow, 0);
	ShowRow(n_RFQRow, 0);
	ShowRow(n_UDSRow, 0);
		
	IF ( [n_DebtMode] = 1 ) THEN		
	{
		ShowRow(n_MainOERow, 0);
		ShowRow(n_DeptEntry, 1);
	}  ELSE
	{
		ShowRow(n_MainOERow, 1);
		ShowRow(n_DeptEntry, 0);
	}
	
	[n_AmendWnd] := 1 ;
 	
	[n_AdvanceOptPane] := 0 ; 
	[n_RecentTransPane] := 0 ;	
	
	CALL UpdateAMENDLayoutAndHeight;
	CALL OnExpandButtonClicked "60000", "1"; 
}


##########################################################	
PROCEDURE InitLayout
		DECLARE PARAMETER sParam1 AS TEXT DO
{
	[n_RecentTransPane]  := 0;
	[n_AdvanceOptPane]   := 0;
	[n_ExtHeaderPane]    := 0;
	[n_ExtMore] 		:= 0 ;
	[n_ExtMoreShrinked] := 0 ;
	
	[n_ExtHeaderPanePerf]   := [n_ExtHeaderPane];
	[n_AmendWnd] := 0;
	[n_OrderMode] := 0 ;
	CALL UpdateLayoutAndHeight;
}

##########################################################
PROCEDURE OnExpandButtonClicked
		 DECLARE PARAMETER sButton 		 AS TEXT
		 DECLARE PARAMETER sExpandState  AS TEXT DO
{
	DECLARE VARIABLE nBtn 		AS QUANTITY
	DECLARE VARIABLE nState     AS QUANTITY
		
	[nBtn]   := StrToInt([sButton]);
	[nState] := StrToInt([sExpandState]);	
	
	IF ( [nBtn] = n_BtnAdvancedOpt ) THEN
	{
		[n_AdvanceOptPane] := [nState];
	}
	ELSE IF ( [nBtn]= n_BtnRecentTransact ) THEN
	{
		[n_RecentTransPane] := [nState];
	}
	ELSE IF ( [nBtn] = n_BtnDashboard ) THEN
	{
		[n_ExtHeaderPane] := [nState];
	} 
	ELSE IF ( [nBtn] = n_BtnMore ) DO
	{
		[n_ExtMore] := [nState];
	} 
	CALL UpdateLayoutAndHeight;	
}

##########################################################	
PROCEDURE SetHeightForSnapQuote
		DECLARE PARAMETER sParam1 AS TEXT DO
{
	IF ([n_AmendWnd] = 1) DO
	{
		RETURN
	}
	
	[n_ExtHeaderPane] := StrToInt([sParam1]);
	[n_ExtHeaderPanePerf]   := [n_ExtHeaderPane];
	
	CALL UpdateLayoutAndHeight;
}

##########################################################	
PROCEDURE OnHideResetSnapQuote DO
{
	IF ([n_AmendWnd] = 1) DO
	{
		RETURN
	}
	
	[n_ExtHeaderPane] := [n_ExtHeaderPanePerf];
	CALL UpdateLayoutAndHeight;
}

##########################################################
PROCEDURE SetAmendWndHeight DO
{
	[n_AmendWnd] := 1;
	
	DECLARE VARIABLE 	nWndID 		AS QUANTITY
	[nWndID] := GetWndID();
	SetWndHeight([nWndID], 157);
}


##########################################################
PROCEDURE SetAmendWndHeightForSpreads DO
{
	[n_AmendWnd] := 1;
	
	DECLARE VARIABLE 	nWndID 		AS QUANTITY
	[nWndID] := GetWndID();
	SetWndHeight([nWndID], 187);
}

##########################################################
PROCEDURE OnEntryTypeChanged
		DECLARE PARAMETER sButton 	AS TEXT DO
{
	DECLARE VARIABLE nBtn 		AS QUANTITY
	[nBtn] := StrToInt([sButton]);			
	
	IF ( [n_ExtMore] = 1 ) DO
	{
		[n_ExtMoreShrinked] := 1 ; 
		CALL OnExpandButtonClicked "60000", "0"; 
	} 
	
	[n_OrderMode] := 0 ;
	
	IF ( [nBtn] = n_RadioOrder ) THEN
	{
		[n_OrderMode] := 1 ; 
		IF ( [n_ExtMoreShrinked] = 1 ) DO
		{
			[n_ExtMoreShrinked] := 0 ; 
			CALL OnExpandButtonClicked "60000", "1"; 
		} 
	
		IF ( [n_DebtMode] = 1 ) THEN		
		{
			ShowRow(n_MainOERow, 0);
			ShowRow(n_DeptEntry, 1);
		} ELSE 
		{
			ShowRow(n_MainOERow, 1);
			ShowRow(n_DeptEntry, 0);
		}
		ShowRow(n_QuoteRow, 0);
		ShowRow(n_RFQRow, 0);
		ShowRow(n_UDSRow, 0); 
		
		CALL UpdateLayoutAndHeight;	
		
	}
	ELSE IF ( [nBtn]= n_RadioQuote ) THEN
	{
		ShowRow(n_QuoteRow, 1);
		ShowRow(n_MainOERow, 0);
		ShowRow(n_RFQRow, 0);
		ShowRow(n_UDSRow, 0);
		ShowRow(n_DeptEntry, 0);
	}
	ELSE IF ( [nBtn]= n_RadioRFQ ) THEN
	{
		ShowRow(n_RFQRow, 1);
		ShowRow(n_MainOERow, 0);
		ShowRow(n_QuoteRow, 0);
		ShowRow(n_UDSRow, 0);		
		ShowRow(n_DeptEntry, 0);
	}
	ELSE IF ( [nBtn] = n_RadioUDS ) DO
	{
		ShowRow(n_UDSRow, 1);
		ShowRow(n_MainOERow, 0);
		ShowRow(n_QuoteRow, 0);
		ShowRow(n_RFQRow, 0);	
		ShowRow(n_DeptEntry, 0);		
	}
}

##########################################################
PROCEDURE OnChangeOEMode
		DECLARE PARAMETER sMode 	AS TEXT DO
{
	DECLARE VARIABLE nMode 		AS QUANTITY
	[nMode] := StrToInt([sMode]);			
	
	IF ( [nMode] = n_DeptEntry ) THEN
	{
		[n_DebtMode] := 1 ;		
	}
	ELSE IF ( [nMode]= n_MainOERow ) DO
	{
		[n_DebtMode] := 0 ;
	}

	IF ([n_OrderMode] = 1 ) DO
	{
		CALL OnEntryTypeChanged "30005";
	}
}
		
		

		
		
		
