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

//put additional include files here

/// Iris 10/21/2010 ORG-1303 CLEANUP_XFS_ERROR_CODE

//put your own support static functions here



void debug_log(const int& nCtrl)
{
	Registry reg(HKEY_CURRENT_USER);
	string strKey = GetRegKey();
	
	char szPath[MAXFULLPATH];
	GetTempPath(128, szPath);
	
	string strVal="Control";
	DWORD dwVal;
	string strMsg;
	if(-1==nCtrl)
	{
		reg.GetValue(strKey, strVal, dwVal);	
		
		///DSC 10/05/2010 ORG-1190 LOCALIZE_DEBUG_LOG_PATH_STRING
		//printf("debug_log value is %d.\n0 means logging is off, > 0 means logging is on, \nand value is size of log file ORIGIN_LOG.TXT before overwriting.\nThe ORIGIN_LOG.TXT file is at %s\n", dwVal, szPath);
		ocu_load_msg_str(XF_DEBUGLOG_GET_VAL_AND_PATH, &strMsg, szPath, &dwVal);
		/// Iris 10/21/2010 ORG-1303 CLEANUP_XFS_ERROR_CODE
		//printf(strMsg, dwVal, szPath);
		warning_msg_box(strMsg, false, 'R');
		///End CLEANUP_XFS_ERROR_CODE
		///end LOCALIZE_DEBUG_LOG_PATH_STRING
	}
	else if(0<=nCtrl)
	{
		reg.SetValue(strKey, strVal, nCtrl);
		
		///DSC 10/05/2010 ORG-1190 LOCALIZE_DEBUG_LOG_PATH_STRING
		// printf("debug_log has been set to value %d.\n0 means logging is off, > 0 means logging is on.\nThe ORIGIN_LOG.TXT file is at %s\n", nCtrl, szPath);
		int nInt = nCtrl;
		ocu_load_msg_str(XF_DEBUGLOG_SET_VAL_AND_PATH, &strMsg, szPath, &nInt);
		/// Iris 10/21/2010 ORG-1303 CLEANUP_XFS_ERROR_CODE
		//printf(strMsg);
		warning_msg_box(strMsg, false, 'R');
		///End CLEANUP_XFS_ERROR_CODE		
		///end LOCALIZE_DEBUG_LOG_PATH_STRING
	}
}

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

}

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