#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
/*
 *	Modification Log:
 *	Sim 07-17-2007 ADD_XY_SCALER_OBJECT
 *	Sim 08-21-2007 FINISH_CODE_OF_OUTPUT_XY_SCALE
 *	Fisher 11/14/2007 ADD_MAP_ID_TO_CHM
 */

//put additional include files here
#include <..\originlab\grobj_utils.h>
#include <o8dlg.h>

//put your own support static functions here



void add_xyscale_obj(GraphLayer& igl, const double& xscale, const string& xUnits, const double& yscale, const string& yUnits, const double& left, const double& top, double& oxscale, double& oyscale)
{
	
	double dLeft = left, dTop = top;
	if(dTop == NANUM) 
		dTop = 10 + rnd()*10;
	if(dLeft == NANUM)
		dLeft = 20 + rnd() * 10;
	
	GraphObject go;
	///---Sim 07-17-2007 ADD_XY_SCALER_OBJECT
	//double dd = fabs(igl.Y.To - igl.Y.From) * yscale /100.;
	//add_y_scaler(igl, go, dd, yUnits, dLeft, dTop, true, true);
	double dX = fabs(igl.X.To - igl.X.From) * xscale /100.;
	double dY = fabs(igl.Y.To - igl.Y.From) * yscale /100.;
	///---Sim 08-21-2007 FINISH_CODE_OF_OUTPUT_XY_SCALE
	//add_xy_scaler(igl, go, dX, dY, xUnits, yUnits, dLeft, dTop, true, true);
	if ( add_xy_scaler(igl, go, dX, dY, xUnits, yUnits, dLeft, dTop, true, true) )
	{
		if ( &oxscale != NULL)
			oxscale = dX;
		if ( &oyscale != NULL)
			oyscale = dY;
	}
	///---END FINISH_CODE_OF_OUTPUT_XY_SCALE
	///---END ADD_XY_SCALER_OBJECT
	
}

//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_xyscale_obj_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_xyscale_obj_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	return false;

}

int add_xyscale_obj_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_xyscale_obj_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{
	
	//------ fisher 11/16/07 ADD_MAP_ID_TO_CHM
	if(is_use_origin_chm())
		trGetN.SetAttribute(STR_HELPID_ATTRIB, IDD_XF_ADD_XYSCALE_OBJ);
	
}
//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_xyscale_obj_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
