#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
enum{
	optn_long,
	optn_ls,
};
#include <origin.h>
//put additional include files here

//put your own support static functions here



void newinset(const int& inset, const string& name, string& result, const int& optn, const string& template)
{
	GraphPage gp;
	gp.Create(template);
	
	if(name.GetLength() > 0)
	{
		switch(optn)
		{
		case 0:
			gp.SetName(name, OCD_KEEP_SN | OCD_LONG_NAME | OCD_ENUM_NEXT);
			break;
		default:
			gp.SetName(name, OCD_LONG_NAME | OCD_ENUM_NEXT);
			break;
		}
	}
	gp.GetName(result);		
	
	GraphLayer glBase=gp.Layers(0);
	string strScript;
	
	strScript.Format("layer.height=%d", 70);		
	glBase.LT_execute(strScript);
	strScript.Format("layer.width=%d", 80);		
	glBase.LT_execute(strScript);
	
	strScript.Format("layer.left=%d", 10);		
	glBase.LT_execute(strScript);
	strScript.Format("layer.top=%d", 15);		
	glBase.LT_execute(strScript);
	
	
	int ii;
	int iNumInset=(inset<5)?4:inset;
	
	int iWidth = (80-(iNumInset-1)*2)/iNumInset-1;
	int iHeight = 20;
	int jj;
	
	for (ii=0; ii<inset; ii++)
	{
			int iLayernum = gp.AddLayer();
	
			GraphLayer gl=gp.Layers(iLayernum);
			
			strScript.Format("layer.height=%d", iHeight);		
			gl.LT_execute(strScript);
			strScript.Format("layer.width=%d", iWidth);		
			gl.LT_execute(strScript);
			
			strScript.Format("layer.left=%d", 90-(ii+1)*(iWidth+2));		
			gl.LT_execute(strScript);
			strScript.Format("layer.top=%d", 15);		
			gl.LT_execute(strScript);
	
			gl.LT_execute("Layer.x.ShowAxes=3");
			gl.LT_execute("Layer.y.ShowAxes=3");
			
	}
	
	
	
}

//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 newinset_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return newinset_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	return false;

}

int newinset_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 newinset_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 newinset_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
