#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>


//----- Modification log
//--- CPY 1/27/08 ADD_COLOR
/// Folger 02/10/09 APPLY_SYMBOL_SIZE_IN_NEW_CREATED_PLOT
/// Folger 03/09/09 QA80-13244 PLOTXY_FAILS_TO_MAKE_BOX_PLOT_WHEN_NO_X_COLUMN



void plotxy(const XYRange& iy, const int& plot, const double& size, const int& rescale, const int& legend, const int& color, GraphLayer& ogl)
{
	
	///------ Folger 03/09/09 QA80-13244 PLOTXY_FAILS_TO_MAKE_BOX_PLOT_WHEN_NO_X_COLUMN
	//int nPlot = ogl.AddPlot(iy, plot);
	int nPlot = ogl.AddPlot(iy, plot, GAP_GROUP_PLOTS | GAP_USE_TEMPLATE | GAP_ALLOW_DUPLICATE_COL | GAP_ALLOW_NO_X);
	///------ End PLOTXY_FAILS_TO_MAKE_BOX_PLOT_WHEN_NO_X_COLUMN
	if(nPlot >=0)
	{
		//----- CPY 1/27/08 ADD_COLOR
		DataPlot dp = ogl.DataPlots(nPlot);
		if(color)
		{
			int nVal = okutil_ocolor_LT_color_convert(color, false); // false = LT color to OCOLOR
			dp.SetColor(nVal);
		}
		//-----
	}
	if(rescale)
		ogl.Rescale();
	if(legend)
		ogl.LT_execute("legend -s");
	
	///------ Folger 02/10/09 APPLY_SYMBOL_SIZE_IN_NEW_CREATED_PLOT
	DataPlot dp = ogl.DataPlots(nPlot);
	if ( dp )
	{
		Tree tr;
		tr = dp.GetFormat(FOB_ALL, FOB_ALL, TRUE, TRUE);
		
		TreeNode trSymbol = tr.Root.Symbol;
		if ( trSymbol && trSymbol.Size )
		{
			trSymbol.Size.nVal = size;
			dp.ApplyFormat(tr, TRUE, TRUE, TRUE);
		}
	}
	///------ End APPLY_SYMBOL_SIZE_IN_NEW_CREATED_PLOT
}

//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int plotxy_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return plotxy_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	return false;

}

int plotxy_make_tree(TreeNode& tr, LPCSTR lpcszVarName)
{
	return false;
}
//nGetNDialog = 0,1,2, corresponding to the XF GetN dropdown, 0 = dialog is not used
//you can change nRet to be one of XFEVT_PROCEED (defualt), XFEVT_ABORT, XFEVT_PROCEED_NO_DLG or XFEVT_PROCEED_WITH_DLG(when nGetNDialog = 0)
//nGetNDialog = -1 when Ok on GetN dialog to allow handler to preocess <auto> etc variables
//dwCntrl is combination of bits
//LTXF_FROM_GUI_MENU, LTXF_FROM_GUI_PROMPT, LTXF_FROM_AUTO_UPDATE, LTXF_FROM_FUNCTION, LTXF_THEME_USED, LTXF_CHANGE_PARAM
void plotxy_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{

}
//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int plotxy_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
