
#ifndef _XF_TREE_H
#define _XF_TREE_H

#define _XF_LT_CALL_IN_VC //CPY 1/27/06

//----CPY 5/17/07 QA70-9794 XF_SEPARATE_INTO_TWO_CLASSES_AND_CACHE
//#define NOTIFY_XF_FILE_CHANGE				okutil_find_files_from_map(NULL, NULL, SUPPORTFILE_XF, FF_UPDATE_MAP); //okutil_find_file(NULL, SUPPORTFILE_XF);
#define NOTIFY_XF_FILE_CHANGE okxf_on_xf_file_save(NULL);
//----

/// YuI 08/08/05 XVAR_ACTION_OBJECT_SHOULD_NOT_DEPEND_ON_ENTIRE_VAR_TREE
//#define	STR_XF_VAR_IO_ATTRIB		"_XF_VAR_IO"		///----Frank 11/18/05 move to tree_utlis.h
/// ML 1/13/2006 XVARIABLEBASE_TO_VC
//#define	STR_XF_VAR_TYPE_ATTRIB		"_XF_VAR_TYPE"
/// end XVARIABLEBASE_TO_VC
/// end XVAR_ACTION_OBJECT_SHOULD_NOT_DEPEND_ON_ENTIRE_VAR_TREE

//enum { IO_INPUT, IO_OUTPUT, IO_INOUTPUT };
bool	is_xvar_output(TreeNode& trVar, bool bExcludeInput = true);
bool	is_xvar_input(TreeNode& trVar, bool bExcludeOutput = true);


#define STR_XF_FILE_EXT_SPEC "[X-Function (*.OXF)] *.OXF"

bool	check_x_function_tree(const TreeNode& trFunc, bool bMustHaveVaris = true);

void OnWksSelectionChange(DataRange &dr, int nEventID);
bool load_XF_events_handler_tree(TreeNode& tr);
bool save_XF_events_handler_tree(TreeNode& tr);
bool get_xf_name(string& strName, int nEventId);

bool check_update_XF_vars_event_handlers(TreeNode& trVars);


/// YuI 10/10/05 QA70-8158 GENERAL_X_STRING_CONVENTION_TO_ACCESS_OBJECTS
bool	XF_error_report(LPCSTR lpcszMessage, LPCSTR lpcszOffendingString);
bool	XF_error_report(int nErrorCode, LPCSTR lpcszOffendingString);
/// end GENERAL_X_STRING_CONVENTION_TO_ACCESS_OBJECTS

///DSC 12/07/05 SEPARATE_XFUNCTIONORGANIZER_FROM_XFUNCTION
void	xf_set_function_name(TreeNode &trFunction, string strName, const int *pnPath=NULL);//	
//BOOL	xf_check_update_function(TreeNode &trFunction, StringArray& arr);
bool	xf_save(TreeNode &trFunction, LPCSTR lpcstrFilePath=NULL);
/// YuI 06/06/08 QA70-8966 XF_DRAG_AND_DROP_PROBLEM
//	void	xf_check_update_before_saving(TreeNode &trXFFunc);
void	xf_check_update_before_saving(TreeNode &trXFFunc, LPCSTR lpcszPathName);
/// end XF_DRAG_AND_DROP_PROBLEM
bool 	xf_save_using_xf_name(TreeNode &trXF);
string	xf_get_category_name(TreeNode &trFunction);
string	xf_get_function_folder(int nPath=SYS_FOLDER, string strSubFolder="");
bool 	xf_construct_xfunction(TreeNode &tr, string strFuncName="", vector<string>& vsVarTypes= NULL);
bool	xf_count_variables(const TreeNode& trXF, int& nInput, int& nOutput, int& nInputOutput);
BOOL	xf_is_autoupdate_possible(const TreeNode& trXF);
void	xf_on_after_add_insert_var(TreeNode& trFunction);
bool 	xf_copy_variable_labels_to_descriptions(TreeNode& trXF, int nLangID=0);
bool 	xf_copy_variable_descriptions_to_labels(TreeNode& trXF, int nLangID=0);
BOOL	xf_check_update_var_type_control_consistency(TreeNode& tr, bool bDisableGUI);
BOOL	xf_check_update_tree_consistancy(TreeNode& tr, bool bInternalXF, bool bDisableGUI);
bool	xf_save_to_default_location(TreeNode& trXF, int nLocation= USER_FOLDER);
///end SEPARATE_XFUNCTIONORGANIZER_FROM_XFUNCTION

Function xf_get_event(TreeNode& trXF, int nEvent);

int get_xvar_type_from_type_name(LPCSTR lpcszTypeName);

///--------------- Jasmine 01/24/06 SHOW_XF_CONTEXT_MENU
bool xf_is_pop_up_menu(TreeNode &trSel, bool &bAdvanView);
TreeNode xf_add_new_var(TreeNode &trVars);
TreeNode xf_insert_new_var(TreeNode &trVars, TreeNode &trBeforeVal);
//----------------
///Jasmine 02/24/06 MOVE_FROM_XFUNCTIONWIZ 
void xf_update_var_node(TreeNode &trVars, const TreeNode &trSettingVar);
void xf_set_var_node(TreeNode &trVar, const TreeNode &trSettingVar, bool bInput);
///End MOVE_FROM_XFUNCTIONWIZ

//------- CPY 5/3/07 QA70-9718 RECENT_IMPORT_EXPORT_WITH_THEME
bool on_theme_save_as(TreeNode& trGetN, const string& strThemeName);
//-------


///Jasmine 03/01/06 REDUCE_SIMILAR_CODE
/*
///Jasmine 02/27/06 GET_XF_STRUCTURE
int xf_get_xf_category(vector<string>& vsCategory, bool bUser = false);
int xf_get_xf_list(vector<string>& vsXF, LPCSTR lpcszCate, bool bUser = false);
///End GET_XF_STRUCTURE
*/
///End REDUCE_SIMILAR_CODE
/// YuI 01/31/06 DOCUMENT_FUNCTIONS_SHOULD_DEAL_WITH_TREE_ONLY
TreeNode 	xf_get_help_node(TreeNode& trXF, int nNodeID , int nLanguage);
void		xf_get_variables(TreeNode& trXF, vector<string>& vsNames, vector<string>& vsValData, vector<string>& vsValTypes, bool bVarTypesAddRef, vector<int>& vnIO, BOOL bInternal);
TreeNode 	xf_get_variable_tree_node(TreeNode& trXF, LPCSTR lpcszName);
/// end DOCUMENT_FUNCTIONS_SHOULD_DEAL_WITH_TREE_ONLY

void xf_update_results_cmd_log_output_options(TreeNode& trXF, DWORD& dwControl);//----- CPY 2/20/2007 QA70-9335 XF_RESULTS_LOG_DUMP_GLOBAL_CONTROL_AND_XF_CONTROL

///Joseph 06/06/07 MOVE_SOME_FUNCTIONS_AND_DEFINITIONS_TO_XFUNCTION_HEADER_FILE
string xf_get_language_string(int nIDLang);
///End MOVE_SOME_FUNCTIONS_AND_DEFINITIONS_TO_XFUNCTION_HEADER_FILE



#pragma dll(@OK)
enum {CALLXFR_OC_ERR, CALLXFR_SUCCESS, CALLXFR_XF_THROW_ERR};
int	DoFunctionCall(Function* pFunction, CallStack* pStack, LPVOID lpReturnValue = NULL, int nXVT = XVT_INT, int* pOCErr = NULL);

#endif //_XF_TREE_H



