#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
//put additional include files here

//put your own support static functions here



void add_graph_to_graph(const string& igname, string& ogname)
{
	
	GraphPageBase gp = Project.Pages();
	if(!gp)
		XF_THROW(XFERR_NO_ACTIVE_GRAPHPAGE);
	
	string strLT;
	// delayed execute is better
	strLT.Format(";dotool -pg %s", igname);
	LT_execute(strLT);
	
	///Cheney 2007-6-20 ADD_INPUT_GRAPH_AND_OUTPUT_TABLE_NAME
	if(ogname)
		ogname = gp.GetName();
	///end ADD_INPUT_GRAPH_AND_OUTPUT_TABLE_NAME
	
}

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

}

int add_graph_to_graph_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 add_graph_to_graph_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{
	
	// we never really want the standard XF dialog to even open
	if(is_empty_or_unassigned(trGetN.igname.strVal))
	{
		string 	strGraphs;
		//--------Folger 07/18/07 CHANGE_PARAMETERS_TO_CLEAN_UP_CODE_IN_GRAPH_BROWSER
		//open_page_preview_list_dlg(GetWindow(), strGraphs, false);
		open_page_preview_list_dlg(GetWindow(), strGraphs, NULL, SHOW_FOLDERS | ENABLE_EMBEDED);
		//--------End CHANGE_PARAMETERS_TO_CLEAN_UP_CODE_IN_GRAPH_BROWSER
		
		if(strGraphs.IsEmpty())
			nRet = XFEVT_ABORT;
		else
			nRet = XFEVT_PROCEED_NO_DLG;
		
		trGetN.igname.strVal = strGraphs;
	}
	
	string	strPage;
	Page	pg = Project.Pages();
	if ( pg )
		strPage = pg.GetName();
	
	if ( trGetN.igname.strVal.CompareNoCase(strPage) == 0 )
		nRet = XFEVT_ABORT;
	
}
//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 add_graph_to_graph_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
