/*------------------------------------------------------------------------------*
 * File Name:				 													*
 * Creation: 																	*
 * Purpose: OriginC Source C file												*
 * Copyright (c) ABCD Corp.	2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010		*
 * All Rights Reserved															*
 * 																				*
 * Modification Log:															*
 * TD 3-14-06 QA70-8579 PAGE_NOT_ACTIVE_ON_SHOW									*
 *	TD 3-14-06 QA70-8579 SAVE_XFUNCTION_INFO_IN_PAGE							*
 *	CPY 3/14/06 MOVE_CODE_TO_USE_COMMON_DYNADLG_BASE_CLASS						*
 *	TD 5-12-06 UGLY_LOOKS_ON_LOAD_MISSING_XFN									*
 *  Joseph 10/08/06  THEME_COMBOBOX_VALIDATE									*
 *	Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE								*
 *	Joseph 10/12/06  ADD_EVENT_THEME_SAVE_AND_SAVEAS							*
 *	Joseph 10/12/06  SHOW_CHOOSER_MODE_DEFAULT									*
 *	Joseph 10/12/06  USE_OPEN_XF_SETTING_WHEN_NOT_USE_LOAD_SETTING				*
 *  Joseph 10/23/06  SUPPORT_MULTI_XFUNCTIONS									*
 *	Joseph 11/24/06	 FIX_BUG_ABOUT_XFBAR_SHOW_WHEN_PAGE_UNACTIVE				*
 *	Joseph 12/05/06	 ON_OPEN_FILE_EVENT											*		
 *	Joseph 12/07/06  ADD_MESSAGE_BOX											*	
 *	Joseph 12/25/06  FIX_BUG_ON_SAVE_THEME										*
 *	Jasmine 02/01/07 GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR						*
 *	Joseph 02/26/07  USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON				*
 *	AW 03/21/07 FIX_MULTI_THEME_ISSUE											*
 * 	Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK								*
 *	Jasmine 03/27/06 DLG_RESIZE_PAINT_MESS										*
 *	Sim 04-02-2007 ADD_UNDO_BUTTON												*
 *	CPY 4/4/2007 CHANGE_PARAMETER_SHOULD_NOT_SUPPORT_THEME_AND_AUTOUPDATE_MODE	*
 *	Sim 04-16-2007 MAKE_SURE_THE_ATTACHED_PAGE_BE_ACTIVE						*
 *	Sim 04-28-2007 FIX_CALL_XF_FROM_OC											*
 *	CPY 5/7/2007 PAGE_XFBAR_SHOW_RECALCULATE_ALWAYS_NEED_GENERAL_XF_TO_GETN_CLEANUP
 *	TD 5-8-07 GETNTREE_THEME_APPLICATION_WITH_RANGES							*
 *	CPY 5/9/07 OPTION_TO_CLEAR_ERR_MSG_ON_EVENT_NOT_WORKING_IN_PAGE_XF_BAR		*
 *	Sim 05-11-2007 FIX_WIZARD_BUTTON_CONTROL									*
 *	CPY 5/11/2007 WIZARD_BETTER_NO_RECALCULATE_AND_RESULTS_LOG_ADDITION			*
 *	Sim 05-16-2007 CLEAR_ERR_MSG_WHEN_CHANGE_PAGE								*
 *	Sim 05-17-2007 FIX_ERR_MSG_WITH_GETN_EVENT_TAGNAME							*
 *	Sim 05-25-2007 GET_XF_BAR_NAME												*
 *	Sim 05-25-2007 IMPROVE_GET_AND_SET_XF_BAR_NAME								*
 *	Joseph 05/30/07 USING_BITMAP_BUTTON_IN_PAGEXFBAR							*
 *	Joseph 06/06/07 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE			*
 *  Joseph 06/21/07 v8.0647 FIX_BUG_GET_BUTTON_DISABLE                          *
 *  Iris 06/29/2007 v8.0652 PFMWIZ_CLICK_FINISH_NOT_TO_CLOSE_XFBAR				*
 *	Sim 06-30-2007 FIX_FACTORY_DEFAULT_THEME_APPIED_ISSUE						*
 *	Sim 06-30-2007 GRAPH_CHANGE_MAY_CAUSE_GUI_CHANGE							*
 *	Sim 07-03-2007 FIX_SAVE_PROJECT_WHEN_XFBAR_WIZARD_MODE						*
 *	Sim 07-04-2007 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE				*
 *	Sim 07-17-2007 FIX_XFBAR_SAVE_AND_OPEN_PROJECT								*
 *	Sim 07-20-2007 QA70-10063-P3 XFBAR_LOADED_FROM_TEMPLATE_SHOULD_SHOW_THEM_AS_TEMPLATE
 *	Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD							*
 *	Sim 07-23-2007 INVOKE_FINISH_EVENT_FOR_XFBAR_WIZARD							*
 *  Iris 07/25/2007 FIX_FAIL_TO_SAVE_THEME_WHEN_CLICK_FINISH_IN_PFMWIZ			*
 *	Sim 07-31-2007 ARRANGE_BUTTON_AUTO_VERTICAL									*
 *	Sim 08-01-2007 POP_HELP_FOR_XF_BAR											*
 *	Sim 08-02-2007 NOT_SHOW_HINT_MESSAGE_AS_NOT_SUPPORT_RIGHT_CLICK_TO_OPEN_XF_PANEL_ON_WIZARD_MODE
 *	Sim 08-31-2007 THEME_CHANGE_SHOULD_CAUSE_APPLY_AGAIN						*
 *	AW 11/07/07 XFBAR_LOCALIZATION												*
 *	Sim 12-06-2007 IMPROVE_EVENT1_PARAM_STR_AUX									*
 *	Sim 02-28-2008 QA80-11156 XF_PANEL_APPLY_BUTTON								*
 *	Sim 02-29-2008 QA80-11156 SUPPORT_EXEC_VALUE_ON_DYNA_DLG					*
 *	Folger 03/03/08 QA80-11192 ADD_THEME_CONTROL_POPUP_MENU						*
 *	CPY 05/22/08 m_btnErrMessage_IS_IN_BASIC_CLASS_DYNA_DLG						*
 *	Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD										*
 *	Folger 07/11/08 FIX_SAVE_DEFAULT_THEME_IN_PAGE_XF_BAR						*
 *	Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON*
 *	Jasmine 08/28/08 QA80-12100 XF_IN_XFBAR_MAY_CLOSE_AFTER_PAGE_DESTROY		*
 *	Jasmine 08/28/08 XFBAR_NO_CLOSE_AGAIN_IF_IT_CLOSE_BY_OTHERS					*
 *	Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
 *	Sim 10-31-2008 INDICATE_THEME_ON_PA_FIT_PARAM_CHANGE						*
 *	Hong 12/17/08 QA80-12798 THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES
 *	Hong 06/05/09 QA80-13483-P1A FIX_ATTACHED_XF_INFO_FAIL_SAVING_INTO_ATTACHED_PAGE_BUT_ACTIVE_PAGE
 *------------------------------------------------------------------------------*/

////////////////////////////////////////////////////////////////////////////////////
// Including the system header file Origin.h should be sufficient for most Origin
// applications and is recommended. Origin.h includes many of the most common system
// header files and is automatically pre-compiled when Origin runs the first time.
// Programs including Origin.h subsequently compile much more quickly as long as
// the size and number of other included header files is minimized. All NAG header
// files are now included in Origin.h and no longer need be separately included.
//
// Right-click on the line below and select 'Open "Origin.h"' to open the Origin.h
// system header file.
#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////
#include "DialogEx.h"
#include "XFunctionEx.h"
#include <xfutils.h> /// YuI 04/18/06
#include <Profiler.h>
//#include <XFbase.h>

#define BASE_WINDOW ResizeDialog//MultiPaneDlg
#define DC_IN_DLG // TD 5-3-06
///Joseph 02/27/07 NOT_USE_OPTIONAL_STRING_ANY_MORE
#define OPTIONAL_XFUNTION  "OptionalXF"   ///Joseph 10/23/06  SUPPORT_MULTI_XFUNCTIONS
///End NOT_USE_OPTIONAL_STRING_ANY_MORE
#include	"DynaDlg.h" //"TreeEditDlg2.h"

#define PROFILE_HRGLASS			waitCursor junk;
#define _SHOW_TIME				Profiler junk;
#define STR_MULTIXF_THEME_ATTRIB   "Is_MultiXFuns"  ///Joseph 10/31/06 Add attribute to multixf theme
//LabTalk Command to use
//page -sps rr[PageXFBar]
#define MAX_CUSTOM_BUTTON_NUM	4 ///---Sim 04-02-2007 MAXIMUM_CUSTOM_BUTTON_NUMBER
////////////////////////////////////////////////////////////////////////////////////
// Include your own header files here.

enum {XFBAR_CHOOSER_MODE = 0, XFBAR_WIZARD_MODE, XFBAR_INDEP_MODE};  ///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE

enum {
XFBAR_XF_NAME_INDEX = 0, 
XFBAR_XF_LIST_INDEX
};

enum {
XFBAR_STATIC_THEME_INDEX = 0,
XFBAR_THEME_COMBO_INDEX,
XFBAR_THEME_SAVE_INDEX,
XFBAR_THEME_SAVEAS_INDEX
};

///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
#define XFBAR_FRAME_WORK_NORMAL						0x0000
#define XFBAR_FRAME_WORK_XF_NO_READY				0x0001
#define	XFBAR_FRAME_WORK_FAILED_EXECUTE_XF			0x0002
///---END IMPROVE_MULTI_THEME_FRAME_WORK
//static string s_strXF_to_open;	///Jasmine 02/01/07 GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR	
static int	s_open_mode = 0; //CPY <0 to indicate static info not defined
////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.

///---Sim 03-26-2007 TEMPORARY_FUNCTION_FOR_THEME_UTILS
#define STR_XF_NAME_ATTRIB "XF_NAME"

/*
static bool theme_tree_to_getn_tree(TreeNode& trTheme, TreeNode& trGetN)
{
	return trGetN.Replace(trTheme, true, true);
}
static bool theme_tree_from_getn_tree(TreeNode& trTheme, TreeNode& trGetN)
{
	return trTheme.Replace(trGetN, true, true);
}
static bool themes_tree_to_file(Tree& trTheme, string strFileName = "" )
{
	if ( strFileName.IsEmpty() )
	{
		//trTheme.GetAttribute(STR_XF_NAME_ATTRIB, strFileName);
		tree_get_theme_file_name(trTheme, strFileName);
		if ( strFileName.IsEmpty() )
			return false;
	}
	else
		//trTheme.SetAttribute(STR_XF_NAME_ATTRIB, strFileName);
		tree_set_theme_file_name(trTheme, strFileName);
	
	return trTheme.Save(strFileName);	
}
static bool themes_tree_from_file(Tree& trTheme, string strFileName = "" )
{
	if ( strFileName.IsEmpty() )
	{
		//trTheme.GetAttribute(STR_XF_NAME_ATTRIB, strFileName);
		tree_get_theme_file_name(trTheme, strFileName);
		if ( strFileName.IsEmpty() )
			return false;
	}		
	else
		//trTheme.SetAttribute(STR_XF_NAME_ATTRIB, strFileName);
		tree_set_theme_file_name(trTheme, strFileName);
	
	return trTheme.Load(strFileName);	
}
*/

static bool	theme_set_class_option(const TreeNode& tr, string& strClassOption)
{
	return tr.SetAttribute(STR_CLASS_OPTION_NAME_ATTRIB, strClassOption);
}

static void	themes_update_last_used(LPCSTR lpcszClassName, TreeNode& trThemes)
{
	theme_update_last_used(lpcszClassName, trThemes, true); // true for theme tree
}
///---END TEMPORARY_FUNCTION_FOR_THEME_UTILS

class CLoadedXfn
{
public:
	CLoadedXfn()
	{
		m_bUnused = FALSE;
	}
	
	void SaveSettings(LPCSTR lpcszName, vector<int> &vnIDs, vector<string> &vsValues)
	{
		///Joseph 11/24/06	 FIX_BUG_ABOUT_XFBAR_SHOW_WHEN_PAGE_UNACTIVE
		//m_bUnused = TRUE;
		m_bUnused = FALSE;
		///End 
		m_strName 	= lpcszName;
		m_vnIDs 	= vnIDs;
		m_vsValues 	= vsValues;
	}
		
	BOOL			m_bUnused;
	vector<int> 	m_vnIDs;
	vector<string> 	m_vsValues;
	string			m_strName;
};


class OC_REGISTERED PageXFBar : public DynaDlg//ResizeDialog
{
public:
	PageXFBar();
	~PageXFBar();
	
	BOOL CreateWindow(int nID, HWND hWnd);
	
	// Called by internal
	BOOL GetSettings(TreeNode &trSplitterPane, Page &page);
	// Called by internal
	BOOL SetSettings(TreeNode &trSplitterPane, Page &page);
	
	
	BOOL OnSelChangeVarNameLine(Control ctrl);
	//BOOL OnXfnUpdate(Control ctrl);

	void 	InvokeGlobalEventOnInitDialog(); // TD 5-2-06
	BOOL 	UpdateXFBarDlg(LPCSTR lpcszName,  bool bResize); /// TD 5-12-06 UGLY_LOOKS_ON_LOAD_MISSING_XFN
	
	void	InvokeGlobalEventOnThemeChange();
	
	///Sandy 2007-4-2 MOVE_GRAPH_OBJECT_EVENT_TO_BASE_CLASS
	/// Iris 12/28/2006 v8.0533 CALL_EVENT1_ON_GRAPH_OBJ_MOVING
	//BOOL 	InvokeGlobalEventOnGraphObjectChange(uint wParam, uint lParam);
	/// end CALL_EVENT1_ON_GRAPH_OBJ_MOVING
	///end MOVE_GRAPH_OBJECT_EVENT_TO_BASE_CLASS
  ///Joseph 12/25/06  FIX_BUG_ON_SAVE_THEME
protected:
///----------------- Message Map ----------------
	EVENTS_BEGIN
		ON_INIT(OnInitDialog) 
		ON_SIZE(OnDlgResize)
		ON_PAGE_SPLITTER_READY(OnReady)
		ON_DESTROY(OnDestroy)	///Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
		
		ON_DC_GENERIC(OnGenericControlMsg) ///Joseph	12/05/06	ON_OPEN_FILE_EVENT
		ON_BN_CLICKED(IDC_APPLY, OnApply)
		ON_BN_CLICKED(IDC_UNDO_BTN, OnUndo) ///---Sim 04-02-2007 ADD_UNDO_BUTTON
		ON_BN_CLICKED(IDC_BTN_CLOSE, OnClose)
		ON_USER_MSG(WM_USER_TREEEDITOR_VALUE_CHANGE, OnAfterValueChange)
		ON_USER_MSG(WM_USER_DYNACTRL_BUTTONGROUP_CLICKED, OnButtonClick)
		///Joseph 10/12/06  ADD_EVENT_THEME_SAVE_AND_SAVEAS
		ON_BN_CLICKED(IDC_XF_THEME_SAVE, OnSaveTheme)
		ON_BN_CLICKED(IDC_XF_THEME_SAVEAS, OnSaveThemeAs)
		
		///Joseph 02/26/07  USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON
		ON_BN_CLICKED(IDC_GETN_CUSTOM_BTN1, OnClickCustomButtom)
		ON_BN_CLICKED(IDC_GETN_CUSTOM_BTN2, OnClickCustomButtom)
		ON_BN_CLICKED(IDC_GETN_CUSTOM_BTN3, OnClickCustomButtom)
		ON_BN_CLICKED(IDC_GETN_CUSTOM_BTN4, OnClickCustomButtom)
		///End USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON
		///End ADD_EVENT_THEME_SAVE_AND_SAVEAS
		
		ON_BN_CLICKED(IDC_BTN_PREVIOUS, OnPrevious)
		ON_BN_CLICKED(IDC_BTN_NEXT, OnNext)
		ON_BN_CLICKED(IDC_BTN_FINISH, OnFinish);
		
		ON_CBN_SELCHANGE(IDC_THEME_COMB, OnComboChangeTheme)  ///Joseph 10/08/06  THEME_COMBOBOX_VALIDATE
				
		///Joseph	12/07/06	ADD_MESSAGE_BOX
		ON_USER_MSG(WM_USER_MSG_BOX, OnMsgBox)
		ON_USER_MSG(WM_USER_MSG_ON_DLG, OnDynamicMsg)//---- CPY 10/26/06 QA70-9063 DYNAMIC_ERR_MSG_IN_GETN_DIALOGS
		///End ADD_MESSAGE_BOX
		
		//ON_CBN_SELCHANGE(IDC_LIST, OnXfnUpdate)
		ON_BN_CLICKED(IDC_LIST, OnChooseFunction)
		//Redirect Selection related messages
//		ON_CHANGE_SELECTION(OnSelectionChange)
//		ON_SELECTION_TRACK(OnSelectionTrack)
		//end --Redirect Selection related messages
		
		ON_USER_MSG(WM_USER_ON_GRAPH_OBJECT_CHANGE, InvokeGlobalEventOnGraphObjectChange)/// Iris 12/27/2006 v8.0533 CALL_EVENT1_ON_GRAPH_OBJ_MOVING
		ON_GETNDLG_MSGS(IDC_GRID)
		
		ON_AFTER_LOAD_FILE(OnLoad)/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS

		ON_RESTORESIZE(OnRestoreSize)  /// TD 3-21-07 QA70-9507 RESIZING_FRAME_TO_FIT_WND_IN_SPLITTER

		ON_HELPINFO(OnHelp) ///---Sim 08-01-2007 POP_HELP_FOR_XF_BAR

	EVENTS_END
///----------------------------------------------
	
	BOOL OnInitDialog();
	BOOL OnReady();
	BOOL OnDestroy();
	BOOL OnDlgResize(int nType, int cx, int cy);
	BOOL OnApply(Control ctrl);
	BOOL OnUndo(Control ctrl); ///---Sim 04-02-2007 ADD_UNDO_BUTTON
	BOOL OnClose(Control ctrl);
	BOOL OnChooseFunction(Control ctrl);
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	/////Joseph 10/12/06  ADD_EVENT_THEME_SAVE_AND_SAVEAS
	//BOOL OnSaveTheme(Control ctrl);
	//BOOL OnSaveAsTheme(Control ctrl);
	///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
	//virtual BOOL SaveTheme(TreeNode& trGetN, LPCSTR lpcszFilename = NULL);
	//virtual BOOL LoadTheme(TreeNode& trGetN, string strTheme);
	virtual BOOL SaveTheme(TreeNode& trGetN, LPCSTR lpcszThemeName);
	virtual BOOL LoadTheme(TreeNode& trGetN, LPCSTR lpcszThemeName);
	///---END CLEAR_THEME_SAVE_METHOD
	/////End ADD_EVENT_THEME_SAVE_AND_SAVEAS
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	/// Hong 12/17/08 QA80-12798 THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES
	//virtual
	BOOL 	CompareTheme(const TreeNode& trGetN, LPCSTR lpcszThemeName, TreeNode& trDiff);
	/// end THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES
	
	//BOOL OnComboChangeTheme(Control ctrl); ///Joseph 10/08/06  THEME_COMBOBOX_VALIDATE
	BOOL OnRestoreSize(DWORD dwSizeInfo);
	///Joseph 10/13/06 QA70-9039 XF_WIZARD_BAR
	BOOL OnPrevious(Control ctrl);
	BOOL OnNext(Control ctrl);
	BOOL OnFinish(Control ctrl);
	///End XF_WIZARD_BAR
	//----------- CPY 2/19/07 CUSTOM_APPLY_BUTTONS_CLEANUP
	//virtual 
	//void OnSpecialButtons(int nEventID, const string& strAux);
	//virtual bool IsSpecialEvent(int nEventID);///Joseph 02/14/07 SUPPORT_MORE_SPECAIL_EVENT
	//virtual 
	bool CheckCustomBottonEvents(int nEventID, int nEventRet, const string& strAux);
	//-----------
	///Joseph 12/07/06  ADD_MESSAGE_BOX
	///Joseph 02/25/06 DO_NOT_ENABLE_BUTTON_ON_SOME_EVENTS
	//void OnEnableButtons(DWORD dwEnable);
	void OnEnableButtons(DWORD dwEnable, int nEventID = GETNE_ON_INIT);
	///End DO_NOT_ENABLE_BUTTON_ON_SOME_EVENTS
	void ResizeDlgControls();
	///End ADD_MESSAGE_BOX
	//bool loadThemeFilesToCombo(const TreeNode& trGUI);   ///Joseph 12/25/06  FIX_BUG_ON_SAVE_THEME
	BOOL OnAfterValueChange(int nRow, int nCol);
	BOOL OnButtonClick(int n, int i);
	
	virtual void OnInitChangeButtonText(LPCSTR lpcszText); ///Joseph 01/28/07 CHANGE_XF_APPLY_BUTTON_TEXT
	//Redirect Selection related messages
//	BOOL OnSelectionChange();
//	BOOL OnSelectionTrack();
	//end --Redirect Selection related messages
	BOOL OnLoad();/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
	//------ 
	
	///Joseph 04/12/07 FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1
	virtual bool GetDlgSpecialButtonStatus(DWORD& dwEnables, int nEventID);
	///End FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1
	
	BOOL OnClickCustomButton(int nID);	///Joseph 04/13/07 SHOULD_SUPPORT_MORE_CUSTOMBUTTON_EVENT
	
	///---Sim 02-28-2008 QA80-11156 XF_PANEL_APPLY_BUTTON
	virtual int				DoApply(TreeNode& trGetN);
	virtual bool			CheckApplyButtonEvent(TreeNode& trGetN, int nEventID, int nEventReturn, LPCSTR lpcszAux, int* pnApplyReturn = NULL);
	
	virtual bool IsDefaultShowApplyButton();
	///---END QA80-11156 XF_PANEL_APPLY_BUTTON
	
	bool Close();///---Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
private:
	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	//bool					m_bShowChooser;
	int 					m_nMode;
	///Joseph 02/28/07	XF_WIZ_CLEANUP
	//not use this tree, we should keep the xf same setting before current xf, ignore the following
	//Tree					m_trCurrentTheme;   //the current tree can be save as file
	///End XF_WIZ_CLEANUP
	//Tree					m_trLastTheme;  //the tree is be loaded from theme file
	Tree					m_trCurrentThemes;  //the current operation tree
	//--------------- CPY 2/26/2007 XF_WIZ_CLEANUP
	//BOOL 					m_bIsNotFirstXF;
	int						m_nWizStep;
	//int						m_nWizMaxStep;///---Sim 03-28-2007 NO_USE_AGAIN
	vector<string>			m_vsXFNames;
	
	bool					m_bCloseDone;///Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	bool					m_bKillOneself;	///Jasmine 08/28/08 XFBAR_NO_CLOSE_AGAIN_IF_IT_CLOSE_BY_OTHERS
private:
	bool	checkAddNext(const string& strXF)
	{
		if(strXF.IsEmpty())
		{
			//m_nWizMaxStep = m_nWizStep;///---Sim 03-28-2007 NO_USE_AGAIN
			return false;
		}
		//	return error_report("PageXFBar checkAddNext found empty XF specified";
		if(m_vsXFNames.GetSize() == m_nWizStep+1)
		{
			m_vsXFNames.Add(strXF);
			return true;
		}
		return false;
	}
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	bool	checkRemoveAfterCurXFs()
	{
		if(m_vsXFNames.GetSize() > m_nWizStep + 1)
		{
			m_vsXFNames.RemoveAt(m_nWizStep + 1, m_vsXFNames.GetSize() - (m_nWizStep + 1));
			//m_nWizMaxStep = m_nWizStep;///---Sim 03-28-2007 NO_USE_AGAIN
			return true;
		}
		return false;
	}
	bool	getCurXF(string& strXF)
	{
		if(m_nWizStep < m_vsXFNames.GetSize())
		{
			strXF = m_vsXFNames[m_nWizStep];
			return true;
		}
		return false;
	}
	bool	getNextXF(string& strXF, bool bGoToNext = true)
	{
		if(m_nWizStep + 1 < m_vsXFNames.GetSize())
		{
			strXF = m_vsXFNames[m_nWizStep + 1];
			if ( bGoToNext )
				goNextXF();
			return true;
		}
		return false;
	}
	bool	getPrevXF(string& strXF, bool bGoToPrev = true)
	{
		if(m_nWizStep > 0)
		{
			strXF = m_vsXFNames[m_nWizStep - 1];
			if ( bGoToPrev )
				goPrevXF();
			return true;
		}
		return false;
	}
	bool	goNextXF()
	{
		if(m_nWizStep + 1 < m_vsXFNames.GetSize())
		{
			m_nWizStep++;
			return true;
		}
		return false;
	}
	bool	goPrevXF()
	{
		if(m_nWizStep > 0)
		{
			m_nWizStep--;
			return true;
		}
		return false;
	}
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	///Joseph 03/01/07 XF_WIZ_CLEANUP
	//create gui
	//bool setGUICorrectStep(LPCSTR lpcszName)
	//{
		//string strName(lpcszName);
		//if(strName.IsEmpty())
		//{
			//out_str("No xf GUI Jump");
			//return false;
		//}
		//TreeNode trCurrentNode;
		//int nIndex = tree_get_subnode_index(m_trCurrentThemes, strName);
		//if( nIndex >= 0)
			//m_nWizStep = nIndex;
		//
		//trCurrentNode = m_trCurrentThemes.GetNode(strName);
		//if(trCurrentNode)
		//{
			//while(trCurrentNode)
			//{
				//TreeNode trNeedDel = trCurrentNode;
				//trCurrentNode = trCurrentNode.NextNode;
				//trNeedDel.Remove();
			//}
		//}
		//else
		//{
			//m_nWizStep ++;
			//checkAddNext(lpcszName);
		//}
		//setControl(lpcszName, true);
		//return false;
	//}
	///End XF_WIZ_CLEANUP
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	void initThemeTree(TreeNode& trThemes)
	{
		trThemes.Reset();
		//trThemes.SetAttribute(STR_MULTIXF_THEME_ATTRIB, true);
		trThemes.SetAttribute(STR_THEME_TYPE_ATTRIB, THTYPE_XFUNCTION);
	}
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
private:
	//--------------- end XF_WIZ_CLEANUP
	///Joseph 02/27/07 NOT_USE_OPTIONAL_STRING_ANY_MORE
	//string 					m_strOptionalFun;  //Optional Xfuntion, format is [xfun1],[xun2],
	///End NOT_USE_OPTIONAL_STRING_ANY_MORE
	///End ADD_CHOOSE_INDEP_WIZARD_MODE
	bool					m_bShowApplyBtn;
	TreeNode 				m_trXF;
	TreeNode				m_input_tr;
	//----- CPY 3/14/06 MOVE_CODE_TO_USE_COMMON_DYNADLG_BASE_CLASS
//	Tree					m_localTr;// used to be in TreeEditControl
	//-----
	XFBase 					m_XF;
//	DynaControl				m_dynCntrl;
	//ComboBox 				m_combo;
	ComboBox				m_comboTheme;
	Control					m_btnChooser;
	Control					m_applyBtn;
	Control					m_staticXFname;
	Control					m_staticXFDescription;
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	Control					m_btnUndo;
	Control					m_btnFinish;
	Control					m_btnPrev;
	Control					m_btnNext;
	Button					m_chkAutoApply;
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	/// TD 3-14-06 QA70-8579 PAGE_NOT_ACTIVE_ON_SHOW
	///Joseph 02/07/07 FIX_BUG_ON_MORE_PAGES
	//Page					m_wp;
	Page 					m_wp;
	///End FIX_BUG_ON_MORE_PAGES
	CLoadedXfn				m_XfnLoaded;
	/// end PAGE_NOT_ACTIVE_ON_SHOW
	
	//string 					m_strXFList;	///Joseph 02/28/07	XF_WIZ_CLEANUP
	///Joseph 03/11/07	XF_WIZ_CLEANUP
	//bool					m_bApply;
	//bool					m_bCustomClicked;
	bool					m_bClickFinished;
	///End XF_WIZ_CLEANUP
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
	string					m_strClassOption;
	//string					m_strTheme;
	//bool					m_bPreventUpdateFWButton; // for not update frame work button twice
	int						m_nFrameWorkState;
	bool					m_bHasNextXF;
	bool					m_bHasPrevXF;
	
	bool					m_bRestoreXFMode;
	
	bool 					m_bApplied;
	bool 					m_bEnableAutoApply;
	
	bool 					m_bRepeatingApply;
	
	bool					m_bXFDone;
	///---END IMPROVE_MULTI_THEME_FRAME_WORK	
	
	bool					m_bThemeDlg;		///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
	
	///Joseph 05/30/07 USING_BITMAP_BUTTON_PAGEXFBAR
	BitmapRadioButton		m_btnSave;
	
	BitmapRadioButton		m_btnSaveAs;
	///End USING_BITMAP_BUTTON_PAGEXFBAR
	
private:
	void					updateShowControls();
	//void updateCombo();
	//BOOL updateControl(bool bForceResize = false);
	BOOL					functionChooser(string &strXF, LPCSTR lpcszDefault, bool bSetShowChooser);
	BOOL					setFunction(LPCSTR lpcszXFname = NULL, bool bSetShowChooser = false);
	BOOL					setControl(LPCSTR lpcszXF, bool bForceResize = false);
	PEVENT_GETN 			getEventHandler(TreeNode& trXF);
	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	bool 					changeLabelToXFName(const TreeNode& trNode, string& strLabel);
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	//void 					beforeNextUpdateThemeTree(string strLabel);
	//bool 					beforPreviousUpdateThemeTree(string strLabel);
	bool					updateThemeTree(TreeNode& trThemeGroup, string strLabel, TreeNode trGetN, bool bToGetN = false);
	bool					updateCurrentTheme(bool bToGetN = false);
	bool 					theme_load_on_new_sel_multixfs(Tree& trThemes, string strSel, TreeNode trGetN);
	//bool 					xfbar_theme_change_gui_multixfs(const TreeNode& trTheme, string strLabel, Tree& tr);
	///---End IMPROVE_MULTI_THEME_FRAME_WORK
	void					setOptioalXFCtrlText(const uint OptionalItem, string & strText);
	///Joseph 02/25/07 DISABLE_BUTTON_BEFORE_APPLY
	//void 					enableOptionalButton();
	//void 					enableOptionalButton(bool bEnable = true);
	///End DISABLE_BUTTON_BEFORE_APPLY
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
	//bool 					checkOptionalXFClicked();
	///---END IMPROVE_MULTI_THEME_FRAME_WORK	
	bool 					initGetNTree(TreeNode& trGetN);  ///Joseph 10/31/06 Update GetNTree label
	///End ADD_CHOOSE_INDEP_WIZARD_MODE

	BOOL 					callXF();
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
	//bool					unUoExecuteXF(TreeNode& trGetN); ///Joseph 03/05/07 XF_WIZ_CLEANUP
	///---END IMPROVE_MULTI_THEME_FRAME_WORK	
	///Joseph Sim	04/04/07 IMPROVE_MULTI_THEME_FRAME_WORK
	//load factory default
	bool					setDefautlValuetoGetNTree(TreeNode& trGetN);
	///End IMPROVE_MULTI_THEME_FRAME_WORK
	
	void 					postGraphObjectMessageOnWizMode(bool bCreate);		///Joseph 06/06/07 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
};

//-------------------------
// implement

PageXFBar::PageXFBar()
 : DynaDlg(IDD_WKS_CTRLRGN, NULL, "Odlg8")
{
	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	//m_bShowChooser = true;
	m_nMode = s_open_mode;
	if(m_nMode == XFBAR_CHOOSER_MODE)
		m_XfnLoaded.m_bUnused = false;
	else 
		m_XfnLoaded.m_bUnused = true;
	///End ADD_CHOOSE_INDEP_WIZARD_MODE
	m_bShowApplyBtn = true;
	//----CPY 2/26/2007 XF_WIZ_CLEANUP
	//m_bIsNotFirstXF = 0;   ///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	m_nWizStep = 0;
	//----
	///Joseph 02/07/07 FIX_BUG_ON_MORE_PAGES
	///// TD 3-14-06 QA70-8579 PAGE_NOT_ACTIVE_ON_SHOW
	//m_wp = Project.Pages();
	///// end PAGE_NOT_ACTIVE_ON_SHOW
	m_wp = Project.Pages();
	///End FIX_BUG_ON_MORE_PAGES
	///Joseph 02/28/07	XF_WIZ_CLEANU
	//m_trCurrentTheme.SetAttribute(STR_MULTIXF_THEME_ATTRIB, true);  ///Joseph 10/31/06 Add attribute to multixf theme
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	//m_trCurrentThemes.SetAttribute(STR_MULTIXF_THEME_ATTRIB, true);
	initThemeTree(m_trCurrentThemes);
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	///End XF_WIZ_CLEANUP
	///Joseph 03/11/07	XF_WIZ_CLEANUP
	//m_bApply = false;		
	m_bClickFinished = false;
	///End XF_WIZ_CLEANUP
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	m_strClassOption.Empty();
	//m_bPreventUpdateFWButton = false;
	//m_strTheme.Empty();	
	m_nFrameWorkState = XFBAR_FRAME_WORK_NORMAL;
	m_bHasNextXF = false;;
	m_bHasPrevXF = false;
	
	m_bRestoreXFMode = false;
	
	m_bApplied = false;
	m_bEnableAutoApply = true;
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	
	m_bCloseDone = false;	///Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	m_bKillOneself = true;	///Jasmine 08/28/08 XFBAR_NO_CLOSE_AGAIN_IF_IT_CLOSE_BY_OTHERS
	
}
PageXFBar::~PageXFBar()
{
}

/// TD 3-14-06 QA70-8579 PAGE_NOT_ACTIVE_ON_SHOW
///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
//#define SHOW_CHOOSER    "ShowChooser"
#define SHOW_MODE		"ShowMode"
///End ADD_CHOOSE_INDEP_WIZARD_MODE
#define FUNCTION_NAME 	"XFunction"
#define FUNC_VALS		"XFValues"
#define FUNC_IDS		"XFIds"
/// end PAGE_NOT_ACTIVE_ON_SHOW

// Save Settings into Pane	
BOOL PageXFBar::GetSettings(TreeNode &trSplitterPane, Page &page)
{
	///---Sim 07-03-2007 FIX_SAVE_PROJECT_WHEN_XFBAR_WIZARD_MODE
	// hard to save wizard info, so ignore it
	if ( XFBAR_WIZARD_MODE == m_nMode )
		return FALSE;
	///---END FIX_SAVE_PROJECT_WHEN_XFBAR_WIZARD_MODE
	
	/// TD 3-14-06 QA70-8579 SAVE_XFUNCTION_INFO_IN_PAGE
	if(trSplitterPane)
	{
		vector<int> vnIDs;
		vector<string> vsValues;
		tree_get_values_with_ids(GetTree(), vnIDs, vsValues);
		TreeNode tn = trSplitterPane.AddNode(FUNCTION_NAME);
		/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
		//tn.strVal = m_trXF.XFname.strVal;
		//page.Info.SYSTEM.XFUNCTION.NAME$ = m_trXF.XFname.strVal;	///Jasmine 02/01/07 GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR, move to XFBarSet
		/// end SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
		tn = trSplitterPane.AddNode(FUNC_VALS);
		tn.strVals = vsValues;
		tn = trSplitterPane.AddNode(FUNC_IDS);
		tn.nVals = vnIDs;
		///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
		//tn = trSplitterPane.AddNode(SHOW_CHOOSER);
		//tn.nVal = m_bShowChooser;//CPY 3/30/06
		tn = trSplitterPane.AddNode(SHOW_MODE);
		tn.nVal = m_nMode;
		///End ADD_CHOOSE_INDEP_WIZARD_MODE
	}
	/// end SAVE_XFUNCTION_INFO_IN_PAGE
	return TRUE;
}
// Load Settings from Pane
BOOL PageXFBar::SetSettings(TreeNode &trSplitterPane, Page &page)
{
	/// TD 3-14-06 QA70-8579 SAVE_XFUNCTION_INFO_IN_PAGE
  	if(trSplitterPane)
  	{
  		TreeNode tn = trSplitterPane.GetNode(FUNCTION_NAME);
  		if(tn)
  		{
	  		if(page)// open project will have invalid page
	  		{
	  			//----- CPY 7/18/07 QA70-9953 XFBAR_SHOULD_NOT_ISSUE_LT_WIN_DASH_A_COMMAND
	  			/*
	  			///Joseph 11/24/06	 FIX_BUG_ABOUT_XFBAR_SHOW_WHEN_PAGE_UNACTIVE
	  			//When we change folder on Project Explore, should show/hide xf_bar correctly;
	  			//active the page(containing the xf_bar)
	  			string strPageName = page.GetName();
				LT_execute("win -a " + strPageName);
	  			///End FIX_BUG_ABOUT_XFBAR_SHOW_WHEN_PAGE_UNACTIVE
	  			*/
	  			//-----
				/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
				//if(!tn.strVal.IsEmpty())
				string strXFname = page.Info.SYSTEM.XFUNCTION.NAME$;
				if(!strXFname.IsEmpty())
				/// end SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
				{
					/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
					//string strXFname = tn.strVal;
					/// end SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
					tn = trSplitterPane.GetNode(FUNC_VALS);
					if(tn)
					{
						vector<string> vsValues;
						vsValues =tn.strVals;
						tn = trSplitterPane.GetNode(FUNC_IDS);
						if(tn)
						{
							vector<int> vnIDs;
							vnIDs = tn.nVals;
							m_XfnLoaded.SaveSettings(strXFname, vnIDs, vsValues);
							///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
							//tn = trSplitterPane.GetNode(SHOW_CHOOSER);
							tn = trSplitterPane.GetNode(SHOW_MODE);
							///End ADD_CHOOSE_INDEP_WIZARD_MODE
							if(tn)
								///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
								//m_bShowChooser = tn.nVal; 
								m_nMode = tn.nVal;
								///End ADD_CHOOSE_INDEP_WIZARD_MODE
						}
					}
				}
				m_wp = page; ///---Sim 07-17-2007 FIX_XFBAR_SAVE_AND_OPEN_PROJECT temporary fix
	  		}
  		}
  		else
  		{
  			out_str("pane storage missing");
  			return false;
  		}
  	}
	/// end SAVE_XFUNCTION_INFO_IN_PAGE
	return TRUE;
}
///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
bool PageXFBar::changeLabelToXFName(const TreeNode& trNode, string& strLabel)
{
	if(!trNode)
		return false;
	if(trNode.GetAttribute(STR_LABEL_ATTRIB, strLabel))
	{
		int nIndex = strLabel.Find(" ");
		if(nIndex > 0)
			strLabel = strLabel.Left( nIndex );
		else
			strLabel = strLabel;
	}
	else
		strLabel = trNode.tagName;
	return true;
}
///End ADD_CHOOSE_INDEP_WIZARD_MODE

BOOL PageXFBar::CreateWindow(int nID, HWND hWnd)
{
	InitMsgMap();
	int nRet = Dialog::Create(hWnd, DLG_AS_CHILD);
	HWND hWndThis = GetSafeHwnd();
	SetWindowLong(hWndThis, GWL_ID, nID);
	return nRet;
}
///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
/*
///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
bool PageXFBar::theme_load_on_new_sel_multixfs(Tree& trThemes, string strSel, TreeNode trGetN)
{
	if ( THEME_FILENAME_FACTORY_DEFAULT != strSel )
	{
		string strClassOption;
		theme_get_class_option(trGetN, strClassOption);
		
		string strThemeFilename = theme_get_settings_file(strSel, strClassOption, tree_get_theme_type(trGetN));
		if(strThemeFilename.IsEmpty())
			return false;
		trGetN.SetAttribute(STR_THEME_FILE_ATTRIB, strThemeFilename);

		//trTheme.Load(strThemeFilename);
		themes_tree_from_file(trThemes);//, strThemeFilename);
		
		return true;
	}
	else
	{
		string strThemeLastUsed; // unfinish
		trGetN.SetAttribute(STR_THEME_FILE_ATTRIB, strThemeLastUsed);
	}

	return false;
}
*/
/*
bool PageXFBar::xfbar_theme_change_gui_multixfs(const TreeNode& trThemes, string strLabel, Tree& trGetN)
{
	TreeNode trTheme;		
	trTheme = trThemes.FindNodeByAttribute("XF_NAME", strLabel);
	if(!trTheme || trTheme.GetNodeCount() <= 0)
		return false;
	//octree_copy_values_by_id(&trNode, &tr, true, STR_ID_ATTRIB, STR_DATAID_ATTRIB);
		
	//UpdateDynaControl(true, GETNEVENT_ON_THEME, true, DYNACONTROL_UPDATE_RECONSTRUCT);			
	//OnChangeTheme(strSel, tr);
	
	return theme_tree_to_gent_tree(trTheme, trGetN);
	//return true;
}
*/
///End ADD_CHOOSE_INDEP_WIZARD_MODE
///---END IMPROVE_MULTI_THEME_FRAME_WORK
///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
/*
///Joseph 10/08/06  THEME_COMBOBOX_VALIDATE
BOOL PageXFBar::OnComboChangeTheme(Control ctrl)
{
	string strSel;
	//if ( m_comboTheme.GetCurSel() > 0 )
	m_comboTheme.GetLBText(m_comboTheme.GetCurSel(),strSel);
	//else 
		//strSel.Empty();
	//updateSaveButton(strSel);
	
	TreeNode trGetN = GetTree();
	
	//string strLabel;
	//tr.GetAttribute(STR_CLASS_OPTION_NAME_ATTRIB, strLabel);
	
	if(m_nMode == XFBAR_WIZARD_MODE)
	{
		m_trCurrentThemes.Reset();
		if( !theme_load_on_new_sel_multixfs(m_trCurrentThemes, strSel, trGetN))
			return false;
	 	//xfbar_theme_change_gui_multixfs( m_trCurrentThemes, strLabel, tr);
	 	updateCurrentTheme(true); // update to current dialog
	}
	else
	{
		if( ! theme_update_on_new_sel(trGetN, strSel) )
		{
			printf("failed to load theme = %s\n", strSel);
			return false;
		}
	}
	
	UpdateDynaControl(true, GETNEVENT_ON_THEME, true, DYNACONTROL_UPDATE_RECONSTRUCT);			
	//updateThemeDescription(tr, false);
	OnChangeTheme(strSel, trGetN);
	return	true;// event handler always returns true
}
///End THEME_COMBOBOX_VALIDATE
*/
///---END IMPROVE_MULTI_THEME_FRAME_WORK
BOOL	PageXFBar::OnChooseFunction(Control ctrl)
{
	return setFunction(NULL);
}


BOOL	PageXFBar::setFunction(LPCSTR lpcszXFname, bool bSetShowChooser)
{
	string		strXF;
	BOOL		bb = functionChooser(strXF, lpcszXFname, bSetShowChooser);
	if (!bb && m_nMode == XFBAR_CHOOSER_MODE)  ///Joseph 10/12/06 There are function chooser in only XFBAR_CHOOSER_MODE
		return FALSE;
	
	ASSERT(!strXF.IsEmpty());
	//------------- CPY 2/26/2007 XF_WIZ_CLEANUP
	if(XFBAR_WIZARD_MODE == m_nMode)
	{
		ASSERT(m_vsXFNames.GetSize()== 0);
		///Joseph 02/28/07	XF_WIZ_CLEANUP
		int nSepIndex = strXF.Find(":");
		if(nSepIndex >= 0)
			strXF = strXF.Right(strXF.GetLength() - nSepIndex - 1);
		///End XF_WIZ_CLEANUP
		strXF.TrimRight("(User) ");
		strXF.TrimLeft();
		m_vsXFNames.Add(strXF);
		m_nWizStep = 0;
		//m_nWizMaxStep = 0; ///---Sim 03-28-2007 NO_USE_AGAIN
	}
	//------------
	return setControl(strXF, true);
}

///Joseph 10/31/06 Copy the label to GetNTree
bool PageXFBar::initGetNTree(TreeNode& trGetN)
{
	//----- CPY 5/7/2007 PAGE_XFBAR_SHOW_RECALCULATE_ALWAYS_NEED_GENERAL_XF_TO_GETN_CLEANUP
	/*
	if(!trGetN.IsValid())
		return false;
	Tree trTempParent;//, trXF, trGetNTemp;
	TreeNode trTemp;
	//string strOxfPath;
	trTemp = trTempParent.AddNode("XFGUI");
	trGetN.Replace(trTemp);
	//----- CPY 4/4/2007 CHANGE_PARAMETER_SHOULD_NOT_SUPPORT_THEME_AND_AUTOUPDATE_MODE
	//okxf_xf_to_getn(&trGetN, &m_trXF, FALSE);
	int nAddOutResultsLog = -1;
	if(m_trXF.askOutResultsLog.nVal > 0)
		nAddOutResultsLog = 1;// default to check for now
	okxf_xf_to_getn(&trGetN, &m_trXF, FALSE, nAddOutResultsLog);
	//-----
	return true;
	*/
	Tree* pRoot = GetTreeRoot();
	//CPY 5/9/07 OPTION_TO_CLEAR_ERR_MSG_ON_EVENT_NOT_WORKING_IN_PAGE_XF_BAR
	//return m_XF.GetGUI(*pRoot, trGetN);
	//---- CPY 5/11/2007 WIZARD_BETTER_NO_RECALCULATE_AND_RESULTS_LOG_ADDITION
	//bool bRet = m_XF.GetGUI(*pRoot, trGetN);
	bool bRet;
	if(XFBAR_WIZARD_MODE == m_nMode)
		bRet = m_XF.GetGUI(*pRoot, trGetN, XFGETN_EX_NONE, XFGETN_EX_NONE);
	else
		bRet = m_XF.GetGUI(*pRoot, trGetN);
	OnSetGetN(trGetN);
	return bRet;
	//-----
}
///End Copy the label to GetNTree
BOOL	PageXFBar::setControl(LPCSTR lpcszXF, bool bForceResize)
{
	string		strXfn = lpcszXF;
	//lpcszXF might also have description, so need to remove it first
	int nPos = strXfn.Find('-');
	if(nPos > 0)
	{
		string strTemp = strXfn.Left(nPos);
		strTemp.TrimRight();
		strXfn = strTemp;
	}
	
	///---Sim 07-04-2007 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
	if ( XFBAR_WIZARD_MODE == m_nMode )
		postGraphObjectMessageOnWizMode(false); 
	///---END FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
	
	///Joseph 11/03/06 Change Label correct
	//if(!m_XF.Load(strXfn, 0, m_trXF, false, true))
	//------ CPY 12/5/06 XF_BAR_ALSO_NEED_TO_HAVE_CORRECT_EVENTS
	// need to bCompile = true to trigger make_tree call
	//if(!m_XF.Load(strXfn, 0, m_trXF, false))
	if(!m_XF.Load(strXfn, LTXF_XFBAR | LTXF_SHOW_DIALOG, m_trXF))
	//------
	///End Change Label correct
	{
		/// TD 5-12-06 UGLY_LOOKS_ON_LOAD_MISSING_XFN
		if(!m_applyBtn.Visible)
		{
			bForceResize = TRUE;
			m_applyBtn.Visible = TRUE;
		}
		UpdateXFBarDlg(NULL, bForceResize);
		/// end UGLY_LOOKS_ON_LOAD_MISSING_XFN
		///---Sim 03-27-2007 ERROR_HANDLE
		//return false;
		return error_report("Load XFunction error!");
		///---END ERROR_HANDLE
	}
	//----- CPY 5/7/2007 PAGE_XFBAR_SHOW_RECALCULATE_ALWAYS_NEED_GENERAL_XF_TO_GETN_CLEANUP
	//TreeNode trGetN = InitTree();
	///Joseph 10/31/06 Copy the label to GetNTree
	/////Joseph 10/08/06  THEME_COMBOBOX_VALIDATE Validate the ThemeComboBox 
	////Them code, don't know how to change it.
	//Tree trTempParent;
	//TreeNode trTemp;
	//trTemp = trTempParent.AddNode("XFGUI");
	//trGetN.Replace(trTemp);
	/////End THEME_COMBOBOX_VALIDATE
////	m_localTr.Reset();	
//
	//if(!okxf_xf_to_getn(&trGetN, &m_trXF, FALSE))
		//return true;
	//initGetNTree(trGetN);
	TreeNode trGetN;
	if(!initGetNTree(trGetN))
		return false;
	//-----
	
	//should not load theme , when open no theme xf
	m_bThemeDlg = is_theme_dialog(trGetN);	///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
	
	//------- CPY 12/5/06 XF_BAR_ALSO_NEED_TO_HAVE_CORRECT_EVENTS
	int nRet = m_XF.InvokeBeforeExecute(trGetN, LTXF_XFBAR);
	//-------
	//m_XF.SetGUI(trGetN); ///---Sim 04-28-2007 FIX_CALL_XF_FROM_OC
	
	///Joseph 01/18/07 APPLY_LAST_USED_THEME_ON_XFBAR
	///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
	//if(m_nMode != XFBAR_WIZARD_MODE)
	if(m_nMode != XFBAR_WIZARD_MODE && m_bThemeDlg)
	///End PAGEXFBAR_SUPPORT_NO_THEME_XF
	{
		string strClassOption;
		trGetN.GetAttribute(STR_CLASS_OPTION_NAME_ATTRIB, strClassOption);	
		theme_apply_analysis_theme(strClassOption, trGetN, NULL);
	}
	///End APPLY_LAST_USED_THEME_ON_XFBAR
	///End Copy the label to GetNTree
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
	else if(m_bThemeDlg)// if(m_nMode == XFBAR_WIZARD_MODE)
	///End PAGEXFBAR_SUPPORT_NO_THEME_XF
	{
		///Joseph 03/30/07 LOAD_LAST_USED_IN_XFBAR_WIZARD_MODE
		/*
		updateCurrentTheme(true); // theme to current dialog
		
		// update getn attribute to let it be used in utils function
		if ( !m_strClassOption.IsEmpty() )
			theme_set_class_option(trGetN, m_strClassOption);
		*/
		
		if ( m_strClassOption.IsEmpty() )  // first time load xfbar
		{
			///Joseph 05/11/07 FIX_BUG_ON_LOAD_LAST_USED_THEME
			//LoadTheme(trGetN, "");
			LoadTheme(trGetN, THEME_FILENAME_LAST_USED); // load last use theme
			///End FIX_BUG_ON_LOAD_LAST_USED_THEME
			theme_get_class_option(trGetN, m_strClassOption);
		}
		else
		{
			updateCurrentTheme(true); // theme to current dialog
			theme_set_class_option(trGetN, m_strClassOption);
		}
		///End LOAD_LAST_USED_IN_XFBAR_WIZARD_MODE

		string strThemeFile;
		tree_get_theme_file_name(m_trCurrentThemes, strThemeFile);
		if ( strThemeFile.IsEmpty() )
			tree_set_theme_file_name(trGetN, NULL);
		else
			tree_set_theme_file_name(trGetN, strThemeFile);
	}
	
	m_nFrameWorkState = XFBAR_FRAME_WORK_NORMAL; // new load xf, frame work state is reset to normal
	///---Sim 05-17-2007 FIX_ERR_MSG_WITH_GETN_EVENT_TAGNAME
	//m_btnErrMessage.Text = ""; ///---Sim 05-16-2007 CLEAR_ERR_MSG_WHEN_CHANGE_PAGE
	m_DynaCntrl.m_strErrMsgSenderTagName = ""; // tagname is empty means clearing error message
	///---END FIX_ERR_MSG_WITH_GETN_EVENT_TAGNAME
	
		//TreeNode trNode;
		///Joseph 02/28/07	XF_WIZ_CLEANUP
		//if( m_comboTheme.GetCurSel() >= 0)
			//{
		///End XF_WIZ_CLEANUP
		//string strXFName;
		//if(!changeLabelToXFName(m_trXF, strXFName))
		//if ( !getCurXF(strXFName);
			//return false;
		
		//trNode = m_trCurrentThemes.GetNode(strXFName);
		//if(trNode)
			//trGetN.Replace(trNode.Clone(), true, true);
		////use theme
		//else if(m_comboTheme.GetCurSel() > 0)
		//{
			/////---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
			////trNode = m_trLastTheme.FindNodeByAttribute("XF_NAME", strXFName);			
			//trNode = m_trCurrentThemes.FindNodeByAttribute("XF_NAME", strXFName);
			/////---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
			//if(trNode.IsValid())
			//{
				////// AW 03/21/07 FIX_MULTI_THEME_ISSUE
				///*
				//TreeNode trTemp;
				//foreach(TreeNode trChild in trNode.Children)
				//{
					//trTemp = tree_get_node_by_dataid(trGetN, trChild.ID);
					//trTemp.nVal = trChild.nVal;
				//}
				//*/
				//octree_copy_values_by_id(&trNode, &trGetN, false, STR_ID_ATTRIB, STR_DATAID_ATTRIB);
				///// END FIX_MULTI_THEME_ISSUE
//
			//}
		//}
		//
	//}
	///End ADD_CHOOSE_INDEP_WIZARD_MODE
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	// check if there are buttons, if buttons, no need for top Apply button
	TreeNode trButton = tree_get_node_by_nodeid(GetTree(), ONODETYPE_PUSHBUTTON_GROUP);
	bool bWasVisible = m_applyBtn.Visible;
	if(trButton)
		m_bShowApplyBtn = false;
	else
		m_bShowApplyBtn = true;
		
	//m_dynCntrl.SetTree(m_localTr, DYNALAYOUT_BACKGROUND_GRAY);
	//if(pfn) //TD 6-2-06 SHOULD_UPDATE_TO_NULL_IF_NOT_PRESENT
	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	//SetEventCallback(NULL, pfn);
	///Joseph 02/27/07 NOT_USE_OPTIONAL_STRING_ANY_MORE
	//if(	!m_strOptionalFun.Compare(OPTIONAL_XFUNTION))
		//return true;
	//else
	//{
	///End NOT_USE_OPTIONAL_STRING_ANY_MORE
		PEVENT_GETN pfn = getEventHandler(m_trXF);
		SetEventCallback(NULL, pfn);
	///Joseph 02/27/07 NOT_USE_OPTIONAL_STRING_ANY_MORE
	//}
	///End NOT_USE_OPTIONAL_STRING_ANY_MORE
	///End ADD_CHOOSE_INDEP_WIZARD_MODE
	SetGrayBackground();
	Set1ColIndent();/// SY 2006-12-18 QA70-9217 v8.0528 EDITABLE_PART_ON_NEXT_LINE_FROM_LABEL
	///Joseph 03/16/07	XF_WIZ_CLEANUP
	//on click finish, should not change gui, but need to set control
	if(m_bClickFinished)
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	{
		invokeBasicGlobalEvent(GETNE_ON_INIT); // init xf getn, but not update dialog
		return true;
	}
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	///End XF_WIZ_CLEANUP
	///---Sim 04-03-2007 ADD_AUTO_APPLY
	m_bEnableAutoApply = false; // close auto apply for prevent error in event function
	UpdateDynaControl(true, GETNEVENT_ON_INIT, true);
	m_bEnableAutoApply = true;
	///---END ADD_AUTO_APPLY
	string strCategory = xf_get_category_name(m_trXF);
	/// TD 5-12-06 UGLY_LOOKS_ON_LOAD_MISSING_XFN
	/*
	m_staticXFname.Text = strXfn;// + " <- " + strCategory;
	m_staticXFDescription.Text = m_trXF.XFdescription.strVal;

	if(m_comboTheme && m_bShowChooser)
	{
	//	m_editThemeDescription = GetItem(IDC_PARAMS_DESCRIPTION);
	//	string strThemeDescription = updateThemeDescription(tr, false);
	//	if(!strThemeDescription.IsEmpty())
	//		m_strDescription = strThemeDescription;
		loadThemeFilesToCombo(GetTree(), m_comboTheme);
	}

	updateShowControls();
	
	if(bForceResize || m_applyBtn.Visible != bWasVisible)
		OnDlgResize(0, GetDlgExtent(false), GetDlgExtent(true));
		
	return TRUE;
	*/
	///---Sim 04-02-2007 ADD_REPEATING_APPLY_MODE
	//return UpdateXFBarDlg(strXfn, (bForceResize || m_applyBtn.Visible != bWasVisible));
	BOOL bRet = UpdateXFBarDlg(strXfn, (bForceResize || m_applyBtn.Visible != bWasVisible));
	m_bRepeatingApply = (m_btnUndo.Visible) ? false : true; 
	return bRet;
	///---END ADD_REPEATING_APPLY_MODE
	/// end UGLY_LOOKS_ON_LOAD_MISSING_XFN
}
/// TD 5-12-06 UGLY_LOOKS_ON_LOAD_MISSING_XFN
BOOL PageXFBar::UpdateXFBarDlg(LPCSTR lpcszName,  bool bResize)
{
	if(lpcszName)
	{
		m_staticXFname.Text = lpcszName;
		///Joseph 10/12/06 Only show description
		//Seperate the Description to menu name and description.
		//m_staticXFDescription.Text = m_trXF.XFdescription.strVal;
		string strDesp,strName;
		/// AW 11/07/07 XFBAR_LOCALIZATION
		//xf_seperate_description(m_trXF.XFdescription.strVal, strName, strDesp);
		TreeNode trDesc;
		if ( octree_get_localization_node(&trDesc, &m_trXF, IDV_HELP_DESCRIPTION, IDXF_DESCRIPTION, IDV_HELP_BRANCH) )
		{
			xf_seperate_description(trDesc.strVal, strName, strDesp);	
		}
		/// END XFBAR_LOCALIZATION
		m_staticXFDescription.Text = strDesp;
		///End Only show description
	}
	else
	{
		m_staticXFname.Text = "";
		m_staticXFDescription.Text = "";
	}
	
	/// Iris 01/04/2007 v8.0536 FIX_AFTER_SAVEAS_THEME_MOVE_GRAPH_OBJ_FAIL_TO_ENTER_EVENT1
	PostMessageOnObjectChange(true, m_wp);
	///end FIX_AFTER_SAVEAS_THEME_MOVE_GRAPH_OBJ_FAIL_TO_ENTER_EVENT1

	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	//if(lpcszName && m_comboTheme && m_bShowChooser)
	//if(lpcszName && m_comboTheme && m_trCurrentThemes.IsEmpty())
	/////End ADD_CHOOSE_INDEP_WIZARD_MODE
	//{
		/////Joseph 12/25/06  FIX_BUG_ON_SAVE_THEME
		////loadThemeFilesToCombo(GetTree(), m_comboTheme);
		//loadThemeFilesToCombo(GetTree());
		/////End FIX_BUG_ON_SAVE_THEME
	//}
	
	updateShowControls();
	//----CPY 2/26/2007 XF_WIZ_CLEANUP
	//ShowCustomButton();	///Joseph 02/26/07  USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON
	//----
	if(bResize)
		OnDlgResize(0, GetDlgExtent(false), GetDlgExtent(true));
	
	return TRUE;
}
/// end UGLY_LOOKS_ON_LOAD_MISSING_XFN

/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
BOOL PageXFBar::OnLoad()
{
	if(m_XfnLoaded.m_bUnused)
	{
		if(!m_staticXFname.Text.IsEmpty())
		{
			// user updated manually
			m_XfnLoaded.m_bUnused = FALSE;
			return TRUE;
		}
		return OnReady();
	}
	return FALSE;
}
/// end SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
BOOL PageXFBar::OnRestoreSize(DWORD dwSizeInfo)
{
	void * p = (void*)dwSizeInfo;
	DLGSIZEINFO *pSz = (DLGSIZEINFO*)p;
	lstrcpyn(pSz->szDialogName, "PageXFBar", MAXLINE);
	pSz->top = -1;
	pSz->left = -1;
	pSz->width = 300;
	pSz->height = 300;
	return TRUE;
}

///---Sim 02-28-2008 QA80-11156 XF_PANEL_APPLY_BUTTON
//virtual
bool PageXFBar::IsDefaultShowApplyButton()
{
	return true;
}
///---END QA80-11156 XF_PANEL_APPLY_BUTTON

void PageXFBar::updateShowControls()
{
	///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
	//m_applyBtn.Visible = m_bShowApplyBtn;
	//uint nChooserItems[] = {IDC_THEME_COMB, IDC_LIST, IDC_BTN_CLOSE, 0};
	//ShowControls(nChooserItems, m_bShowChooser);
//
	//m_staticXFDescription.Visible = false;// we will move this inside DynaControl
//
	///Hide some controls for use 
//----CPY 2/26/2007 XF_WIZ_CLEANUP
//	uint nChooserItems[] = {IDC_XF_THEME_SAVE, IDC_XF_THEME_SAVEAS, IDC_BTN_PREVIOUS, IDC_BTN_NEXT, IDC_BTN_FINISH, IDC_BTN_XFUN1, IDC_BTN_XFUN2, IDC_BTN_XFUN3, 0};
//	uint nIndepItems[] = {IDC_LIST, IDC_BTN_PREVIOUS,  IDC_BTN_NEXT, IDC_BTN_FINISH, IDC_BTN_XFUN1, IDC_BTN_XFUN2, IDC_BTN_XFUN3, 0};
///---Sim 03-31-2007 ADD_AUTO_APPLY_CHECKBOX
	//uint nChooserItems[] = {IDC_XF_THEME_SAVE, IDC_XF_THEME_SAVEAS, IDC_BTN_PREVIOUS, IDC_BTN_NEXT, IDC_BTN_FINISH, 0};
	//uint nIndepItems[] = {IDC_LIST, IDC_BTN_PREVIOUS,  IDC_BTN_NEXT, IDC_BTN_FINISH, 0};
	uint nChooserItems[] = {IDC_XF_THEME_SAVE, IDC_XF_THEME_SAVEAS, IDC_BTN_PREVIOUS, IDC_BTN_NEXT, IDC_BTN_FINISH, IDC_CHK_XFBAR_AUTO_APPLY, 0};
	uint nIndepItems[] = {IDC_LIST, IDC_BTN_PREVIOUS,  IDC_BTN_NEXT, IDC_BTN_FINISH, IDC_CHK_XFBAR_AUTO_APPLY, 0};
///---END ADD_AUTO_APPLY_CHECKBOX
//----
	uint nWizardItems[] = {IDC_LIST, 0};
	switch(m_nMode)
	{
	case XFBAR_CHOOSER_MODE:
		ShowControls(nChooserItems, false);
		break;
	case XFBAR_INDEP_MODE:
		ShowControls(nIndepItems, false);
		break;
	case XFBAR_WIZARD_MODE:
		ShowControls(nWizardItems, false);
		break;
	}
	
	m_applyBtn.Visible = true; ///---Sim 04-04-2007 SUPPORT_NO_APPLY_BUTTON_PAGE apply button default is show
	m_btnUndo.Visible = false; ///---Sim 04-02-2007 ADD_UNDO_BUTTON
	//----CPY 2/26/2007 XF_WIZ_CLEANUP
	ShowCustomButton();
	//----
	///---Sim 04-02-2007 ADD_UNDO_BUTTON
	if ( XFBAR_WIZARD_MODE == m_nMode )
	{
		if ( !m_applyBtn.Visible )
			m_btnUndo.Visible = false;	// undo depend on apply
		m_chkAutoApply.Visible = ( m_applyBtn.Visible && !m_btnUndo.Visible );
	}
	///---END ADD_UNDO_BUTTON
	///End	 ADD_CHOOSE_INDEP_WIZARD_MODE
	
}

BOOL PageXFBar::OnInitDialog()
{
	PROFILE_HRGLASS

	DynaDlg::OnInitDialog(0, "");
	///--- CPY 05/22/08 m_btnErrMessage_IS_IN_BASIC_CLASS_DYNA_DLG
	//Control ctrl = GetItem(IDC_GRID);
	/////Joseph	12/07/06	ADD_MESSAGE_BOX
	//m_btnErrMessage	= GetItem(IDC_ERR_MESSAGE_BOX);  
	//if(m_btnErrMessage)
		//m_btnErrMessage.Text = "";
	/////End ADD_MESSAGE_BOX
	//m_DynaCntrl.CreateControl(ctrl.GetSafeHwnd(),  DYNACONTROL_CREATE_IN_XFBAR);
	InitDynaControl(IDC_GRID);
	//----
	m_applyBtn = GetItem(IDC_APPLY);
	m_btnChooser = GetItem(IDC_LIST);
	
	/////---Sim 03-26-2007 FIX_CANNOT_ACCESS_PRIVATE_MEMBER
	//TreeNode tr = GetTree();
	//InitThemeControls(this, tr, IDC_THEME_COMB, IDC_STATIC_THEME, IDC_XF_THEME_SAVE, IDC_XF_THEME_SAVEAS);
	/////---END FIX_CANNOT_ACCESS_PRIVATE_MEMBER
	m_comboTheme = GetItem(IDC_THEME_COMB);
	m_staticXFname = GetItem(IDC_XF_NAME);
	m_staticXFDescription = GetItem(IDC_DESCRIPTION);
	///Joseph 02/27/07 NOT_USE_OPTIONAL_STRING_ANY_MORE
	//m_strOptionalFun = "";	
	///End NOT_USE_OPTIONAL_STRING_ANY_MORE

	/// Iris 01/04/2007 v8.0536 FIX_AFTER_SAVEAS_THEME_MOVE_GRAPH_OBJ_FAIL_TO_ENTER_EVENT1
	/*
	/// Iris 12/27/2006 v8.0533 CALL_EVENT1_ON_GRAPH_OBJ_MOVING
	HWND 	hwnd = GetSafeHwnd();
	post_getn_dialog_message(PGDM_SET_HDLG, (uint)hwnd);
	///end CALL_EVENT1_ON_GRAPH_OBJ_MOVING
	*/
	////end FIX_AFTER_SAVEAS_THEME_MOVE_GRAPH_OBJ_FAIL_TO_ENTER_EVENT1
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	m_btnFinish = GetItem(IDC_BTN_FINISH);
	m_btnPrev = GetItem(IDC_BTN_PREVIOUS);
	m_btnNext = GetItem(IDC_BTN_NEXT);
	
	m_chkAutoApply = GetItem(IDC_CHK_XFBAR_AUTO_APPLY);
	m_chkAutoApply.Check = 0;
	//if(XFBAR_WIZARD_MODE != m_nMode)
	//{
		//m_chkAutoApply.Visible = false;
	//}
	
	m_btnUndo = GetItem(IDC_UNDO_BTN);
	//m_btnUndo.Visible = false;
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	
	//------ Folger 03/03/08 QA80-11192 ADD_THEME_CONTROL_POPUP_MENU
#ifndef THEME_CONTROL_POPUP_MENU
	///Joseph 05/30/07 USING_BITMAP_BUTTON_IN_PAGEXFBAR
	m_btnSave = GetItem(IDC_XF_THEME_SAVE);
	
	vector<string> vsTips;
	vsTips.Add(_L("Save theme"));
	m_btnSave.Init(1, IDB_PAGEXFBAR_SAVE, 16, vsTips);
	
	m_btnSaveAs = GetItem(IDC_XF_THEME_SAVEAS);
	
	vsTips.RemoveAll();
	vsTips.Add(_L("Save theme as..."));
	m_btnSaveAs.Init(1, IDB_PAGEXFBAR_SAVEAS, 16, vsTips);

	///End USING_BITMAP_BUTTON_IN_PAGEXFBAR
#else
	m_btnSave = GetItem(IDC_XF_THEME_SAVE);
	m_btnSaveAs = GetItem(IDC_XF_THEME_SAVEAS);
	vector<string> vsTips;
	m_btnSaveAs.Init(1, IDB_DROP_DOWN_UP, 16, vsTips);
#endif
	//------ End ADD_THEME_CONTROL_POPUP_MENU
	return true;
}
//----- CPY 7/3/06 QA70-8798 DYNABOX_BETTER_EVENTS
/*
PEVENT_FUNC PageXFBar::getEventHandler(TreeNode& trXF)
{
    int nEventId = trXF.UsageCtxt.mainmenu.GetN.nVal;
    Function fnEvent1 = xf_get_event(trXF, 1);//xf.GetEvent(1);
	PEVENT_FUNC pfnEvent = (PEVENT_FUNC)fnEvent1;
	return pfnEvent;
}
*/
PEVENT_GETN PageXFBar::getEventHandler(TreeNode& trXF)
{
	///Joseph 11/28/06 CLEAN_CODE_XF_BAR
    //int nEventId = trXF.UsageCtxt.mainmenu.GetN.nVal;
    if(!trXF.IsValid())
    {	
    	out_str("The Event Handler Tree is not Invalid!");
    	return NULL;
    }
    ///End CLEAN_CODE_XF_BAR
    Function fnEvent1 = xf_get_event(trXF, 1);//xf.GetEvent(1);
	PEVENT_GETN pfnEvent = (PEVENT_GETN)fnEvent1;
	return pfnEvent;
}
//-----

void 	PageXFBar::InvokeGlobalEventOnInitDialog()
{
	/// CPY Iris 7/20/06 v8.0447 SEPRATE_INIT_AND_THEME_EVENT
	//invokeBasicGlobalEventOnInitDialog();
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	if(XFBAR_WIZARD_MODE != m_nMode)
	{
		invokeBasicGlobalEvent(GETNE_ON_INIT);
	}
	else
	{
		if ( !m_bRestoreXFMode )
			invokeBasicGlobalEvent(GETNE_ON_INIT);
		else
			invokeBasicGlobalEvent(GETNE_ON_RESTORE);
	}
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	///end SEPRATE_INIT_AND_THEME_EVENT	
}

///Sandy 2007-4-2 MOVE_GRAPH_OBJECT_EVENT_TO_BASE_CLASS
/// Iris 12/28/2006 v8.0533 CALL_EVENT1_ON_GRAPH_OBJ_MOVING
//BOOL 	PageXFBar::InvokeGlobalEventOnGraphObjectChange(uint wParam, uint lParam)
//{
	//invokeBasicGlobalEvent(GETNE_ON_GRAPH_OBJECT_CHANGE);
	//return true;
//}
/// end CALL_EVENT1_ON_GRAPH_OBJ_MOVING
///end MOVE_GRAPH_OBJECT_EVENT_TO_BASE_CLASS

///---Sim 05-25-2007 IMPROVE_GET_AND_SET_XF_BAR_NAME
//int XFBarSet(string str = "", int nMode = 0)
int XFBarSet(Page& page, string str = "", int nMode = 0)
///---END IMPROVE_GET_AND_SET_XF_BAR_NAME
{
	///Jasmine 02/01/07 GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR
	//set xf name in page at once, no need s_strXF_to_open
	//s_strXF_to_open = str;
	///---Sim 05-25-2007 IMPROVE_GET_AND_SET_XF_BAR_NAME
	//Page page = Project.Pages();
	if ( !page )
		return -1;
	///---END IMPROVE_GET_AND_SET_XF_BAR_NAME
	page.Info.SYSTEM.XFUNCTION.NAME$ = str;
	///End GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR
	///---Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD
	//page.Info.SYSTEM.XFUNCTION.WIZARD = 0;
	Tree trXFBar;
	tree_get_binary_storage(trXFBar, page, XF_PANEL_BINARY_STORAGE_NAME);
	trXFBar.Wizard.nVal = 0;
	///---END NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD
	///Joseph  10/12/06 SHOW_CHOOSER_MODE_DEFAULT
	if(SXFB_OPEN_CHOOSER == nMode)
		s_open_mode = XFBAR_CHOOSER_MODE;
	///End SHOW_CHOOSER_MODE_WHEN_DEFAULT
	else if(SXFB_OPEN_INDEPENDENT == nMode)
		s_open_mode = XFBAR_INDEP_MODE;
	else
	{	///---Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD
		s_open_mode = XFBAR_WIZARD_MODE;
		//page.Info.SYSTEM.XFUNCTION.WIZARD = 1; ///---Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD
		trXFBar.Wizard.nVal = 1; ///---Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD
	}	///---Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD

	tree_put_binary_storage(trXFBar, page, XF_PANEL_BINARY_STORAGE_NAME); ///---Sim 07-23-2007 NOT_ALLOW_HIDE_XF_PANEL_FOR_WIZARD
	
	return 0;
}

///---Sim 05-25-2007 GET_XF_BAR_NAME
int XFBarGet(Page& page, string& str, int& nMode)
{
	//Page page = Project.Pages();
	if ( !page )
		return -1;
	str = page.Info.SYSTEM.XFUNCTION.NAME$;
	
	switch ( s_open_mode )
	{
	case XFBAR_CHOOSER_MODE:
		nMode = SXFB_OPEN_CHOOSER;
		break;
	case XFBAR_INDEP_MODE:
		nMode = SXFB_OPEN_INDEPENDENT;
		break;
	case XFBAR_WIZARD_MODE:
		nMode = SXFB_OPEN_WIZARD;
		break;
	}
		
	return 0;
}
///---END GET_XF_BAR_NAME
	
BOOL PageXFBar::OnReady()
{
	SetInitReady();
	if(m_XfnLoaded.m_bUnused)
	{
		/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
		//m_XfnLoaded.m_bUnused = FALSE;
		/// end SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
		///Joseph 10/12/06   USE_OPEN_XF_SETTING_WHEN_NOT_USE_LOAD_SETTING
		//if(	setFunction(m_XfnLoaded.m_strName))
		///Jasmine 02/01/07 GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR	
		//if(	setFunction(s_strXF_to_open))
		Page page = Project.Pages();
		string strXFName = page.Info.SYSTEM.XFUNCTION.NAME$;
		Project.UnpackXFunction(strXFName);/// TD 2-19-07 QA70-9340 DELAYED_USER_PROPMPTED_UPDATE_OF_XFBAR_FUNCTIONS
		if(	setFunction(strXFName))
		///End GET_XF_FROM_TEMPLATE_TO_OPEN_XF_BAR	
		///End USE_OPEN_XF_SETTING_WHEN_NOT_USE_LOAD_SETTING
		{
			/// TD 5-15-06 QA70-8579 SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
			m_XfnLoaded.m_bUnused = FALSE;
			/// end SAVING_OXF_IN_PROJECTS_TEMPALTES_AND_SINGLE_WINDOWS
			///Joseph 10/12/06   USE_OPEN_XF_SETTING_WHEN_NOT_USE_LOAD_SETTING
			//tree_set_values_by_ids(THE_TREE_NODE, m_XfnLoaded.m_vnIDs, m_XfnLoaded.m_vsValues);
			//m_DynaCntrl.Update(DYNACONTROL_UPDATE_VALUE);
			///End USE_OPEN_XF_SETTING_WHEN_NOT_USE_LOAD_SETTING
		}
		//return true;
	}
	else 
		///Joseph 11/24/06	 FIX_BUG_ABOUT_XFBAR_SHOW_WHEN_PAGE_UNACTIVE
		//setFunction(s_strXF_to_open, true);
	{
		Project.UnpackXFunction(m_XfnLoaded.m_strName);/// TD 2-19-07 QA70-9340 DELAYED_USER_PROPMPTED_UPDATE_OF_XFBAR_FUNCTIONS
		setFunction(m_XfnLoaded.m_strName, true);
		//----- CPY 7/18/2007 QA70-10063-P3 XFBAR_LOADED_FROM_TEMPLATE_SHOULD_SHOW_THEM_AS_TEMPLATE
		//tree_set_values_by_ids(THE_TREE_NODE, m_XfnLoaded.m_vnIDs, m_XfnLoaded.m_vsValues);
		//-----
		/// TD 5-8-07 GETNTREE_THEME_APPLICATION_WITH_RANGES
		TreeNode trGetN = GetTree();
		//----- CPY 7/18/2007 QA70-10063-P3 XFBAR_LOADED_FROM_TEMPLATE_SHOULD_SHOW_THEM_AS_TEMPLATE
		tree_set_values_by_ids(trGetN, m_XfnLoaded.m_vnIDs, m_XfnLoaded.m_vsValues);
		tree_set_theme_file_name(trGetN, STR_TEMPLATE_THEME);
		//-----
		///---Sim 07-20-2007 QA70-10063-P3 XFBAR_LOADED_FROM_TEMPLATE_SHOULD_SHOW_THEM_AS_TEMPLATE
		int nType = cvt_str_to_predefined_type(STR_TEMPLATE_THEME);
		string strClassOption;
		theme_get_class_option(trGetN, strClassOption);
		/// Hong 06/05/09 QA80-13483-P1A FIX_ATTACHED_XF_INFO_FAIL_SAVING_INTO_ATTACHED_PAGE_BUT_ACTIVE_PAGE
		//theme_active_book_sheet_storage(trGetN, strClassOption, nType, false);
		ASSERT(m_wp);
		theme_active_book_sheet_storage(trGetN, strClassOption, nType, false, NULL, &m_wp);
		/// end FIX_ATTACHED_XF_INFO_FAIL_SAVING_INTO_ATTACHED_PAGE_BUT_ACTIVE_PAGE
		///---END QA70-10063-P3 XFBAR_LOADED_FROM_TEMPLATE_SHOULD_SHOW_THEM_AS_TEMPLATE
		okutil_getn_update_ranges(&trGetN);
		/// end GETNTREE_THEME_APPLICATION_WITH_RANGES
		m_DynaCntrl.Update(DYNACONTROL_UPDATE_VALUE);
	}
		///End FIX_BUG_ABOUT_XFBAR_SHOW_WHEN_PAGE_UNACTIVE
		
	///---Sim 03-26-2007 FIX_CANNOT_ACCESS_PRIVATE_MEMBER
	TreeNode tr = GetTree();
	InitThemeControls(this, tr, IDC_THEME_COMB, IDC_STATIC_THEME, IDC_XF_THEME_SAVE, IDC_XF_THEME_SAVEAS);	
	///---END FIX_CANNOT_ACCESS_PRIVATE_MEMBER

	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	if(XFBAR_WIZARD_MODE == m_nMode)
	{
		//theme_get_class_option(tr, m_strClassOption);
		//
		////m_applyBtn.Visible = false;
		//
		////Control ctrl;
		////OnApply(ctrl);
		//
		////m_bPreventUpdateFWButton = true; // don't change frame work button during run setControl function, those buttons will be updated by frame worker
		invokeBasicGlobalEvent(GETNE_ON_INIT_XFWIZ);
	}
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	
	return true;
}

BOOL PageXFBar::OnDestroy()
{	
	///Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	m_bKillOneself = false;	///Jasmine 08/28/08 XFBAR_NO_CLOSE_AGAIN_IF_IT_CLOSE_BY_OTHERS, here xf bar is closed or is going to close	
	
	///---Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
	//Control ctrl;
	//OnClose(ctrl);
	Close();
	///---END v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
	///End XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	return ResizeDialog::OnDestroy();
}
///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
void	PageXFBar::setOptioalXFCtrlText(const uint OptionalItem, string & strText)
{
	Control ctrl;
	ctrl = GetItem(OptionalItem);
	ctrl.Visible = true;
	strText.TrimLeft(" ["); 
	strText.TrimRight("] ");
	ctrl.Text = strText;
}
///End ADD_CHOOSE_INDEP_WIZARD_MODE
#define MIN_HEIGHT_DYNA 100 ///---Sim 07-31-2007 ARRANGE_BUTTON_AUTO_VERTICAL

BOOL PageXFBar::OnDlgResize(int nType, int cx, int cy)
{
	if(!IsInitReady())
		return TRUE;
	MoveControlsHelper	_temp(this);		///Jasmine 03/27/06 DLG_RESIZE_PAINT_MESS
	///---Sim 03-31-2007 RECODE_RESIZE_DLG
	int nEdge = GetControlGap();
	int nTop = nEdge, nBottom = cy, nLeft = nEdge, nRight = cx - nEdge;
	
	uint uThemeItems[] = {IDC_STATIC_THEME, IDC_THEME_COMB, IDC_XF_THEME_SAVE , IDC_XF_THEME_SAVEAS, 0};
	uint uChooserItems[] = {IDC_XF_NAME, IDC_LIST, 0};
	uint uFunctionItems[] = {IDC_GETN_CUSTOM_BTN1, IDC_GETN_CUSTOM_BTN2, IDC_GETN_CUSTOM_BTN3,  IDC_GETN_CUSTOM_BTN4, IDC_APPLY, IDC_UNDO_BTN, IDC_CHK_XFBAR_AUTO_APPLY, 0, 0};
	uint uWizardItems[] = {IDC_BTN_PREVIOUS, IDC_BTN_NEXT, IDC_BTN_FINISH, 0, 0};
	
	if ( XFBAR_WIZARD_MODE == m_nMode )
		uWizardItems[sizeof(uWizardItems)/sizeof(uint) - 2] = IDC_BTN_CLOSE;
	else
		uFunctionItems[sizeof(uFunctionItems)/sizeof(uint) - 2] = IDC_BTN_CLOSE;

	// from top
	///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
	//nTop = ArrangeControlsLeftRight(uThemeItems, nLeft, nTop, cx, IDC_THEME_COMB);
	
	if(m_bThemeDlg)
		nTop = ArrangeControlsLeftRight(uThemeItems, nLeft, nTop, cx, IDC_THEME_COMB);
	else
		ShowControls(uThemeItems, false);
	///End PAGEXFBAR_SUPPORT_NO_THEME_XF
	
	nTop+= nEdge;
	nTop = ArrangeControlsLeftRight(uChooserItems, nLeft, nTop, cx, IDC_XF_NAME);
	nTop = StretchControlWide(IDC_DESCRIPTION, nLeft, nTop, cx);
	nTop+= nEdge;

	// from bottom
	///---Sim 07-31-2007 ARRANGE_BUTTON_AUTO_VERTICAL
	//nBottom = ArrangeControlsCenterBottom(uWizardItems, cx, nBottom);
	//nBottom = ArrangeControlsCenterBottom(uFunctionItems, cx, nBottom);
	nBottom = ArrangeControlsCenterBottom(uWizardItems, cx, nBottom, -1, true, true);
	nBottom = ArrangeControlsCenterBottom(uFunctionItems, cx, nBottom, -1, true, true);
	///---END ARRANGE_BUTTON_AUTO_VERTICAL

	// error message
	int	nErrMessageHeight; ///---Sim 07-31-2007 ARRANGE_BUTTON_AUTO_VERTICAL
	if ( m_btnErrMessage )
	{
		///---Sim 07-31-2007 ARRANGE_BUTTON_AUTO_VERTICAL
		//int		nErrMessageHeight = GetDlgStatusMsgBoxHeight(nRight - nLeft);
		nErrMessageHeight = GetDlgStatusMsgBoxHeight(nRight - nLeft);
		///---END ARRANGE_BUTTON_AUTO_VERTICAL
		
		if ( nErrMessageHeight > 0 )
		{
			RECT rrMsg;
			rrMsg.left = nLeft;
			rrMsg.right = nRight;
			rrMsg.bottom = nBottom - nEdge;
			rrMsg.top = rrMsg.bottom - nErrMessageHeight;
			MoveControl(m_btnErrMessage, rrMsg);
			
			nBottom -= nErrMessageHeight + nEdge*2;
			
			m_btnErrMessage.Visible = true;
		}
		else
			m_btnErrMessage.Visible = false;
	}
	
	// DynaControl
	RECT rrDyna;
	rrDyna.left = nLeft;
	rrDyna.right = nRight;
	rrDyna.top = nTop;
	rrDyna.bottom = nBottom;
	MoveControl(m_DynaCntrl, rrDyna);
	///---END RECODE_RESIZE_DLG
	
	///---Sim 07-31-2007 ARRANGE_BUTTON_AUTO_VERTICAL
	// not enough space for dyna control
	if ( rrDyna.bottom < rrDyna.top + MIN_HEIGHT_DYNA )
	{
		int nOffset = rrDyna.top + MIN_HEIGHT_DYNA - rrDyna.bottom;
		rrDyna.bottom = rrDyna.top + MIN_HEIGHT_DYNA;
		MoveControl(m_DynaCntrl, rrDyna);
		nTop += MIN_HEIGHT_DYNA;

		/*
		// if has error message
		if (nErrMessageHeight > 0)
		{
			nTop += nEdge;		
			nTop = PositionControl(IDC_ERR_MESSAGE_BOX, nLeft, nTop, true, true);
		}
		
		nTop = ArrangeControlsCenterTop(uFunctionItems, cx, nTop, -1, true, true);
		nTop = ArrangeControlsCenterTop(uWizardItems, cx, nTop, -1, true, true);
		*/
		PositionControlOffset(IDC_ERR_MESSAGE_BOX, nOffset);
		
		int ii;
		for(ii = 0; uFunctionItems[ii] > 0; ii++)
			PositionControlOffset(uFunctionItems[ii], nOffset);
		for(ii = 0; uWizardItems[ii] > 0; ii++)
			PositionControlOffset(uWizardItems[ii], nOffset);
	}
	///---END ARRANGE_BUTTON_AUTO_VERTICAL
	
	return TRUE;
}

///---Sim 02-28-2008 QA80-11156 XF_PANEL_APPLY_BUTTON
/*
BOOL PageXFBar::callXF()
{
	//--------- CPY 5/17/07 QA70-9794 XF_SEPARATE_INTO_TWO_CLASSES_AND_CACHE
	//m_XF.Reset();
	//---------
	//----- CPY 4/4/2007 CHANGE_PARAMETER_SHOULD_NOT_SUPPORT_THEME_AND_AUTOUPDATE_MODE
	//m_XF.Compile();
	//return m_XF.Run(FALSE, GetTree());
	int nErr = m_XF.Compile();
	if(0 == nErr)
	{
		///---Sim 04-28-2007 FIX_CALL_XF_FROM_OC
		//DWORD dwControl = 0;
		//xf_update_results_cmd_log_output_options(m_trXF, dwControl);
		//int nAutoUpdate = AU_NONE;
		//int nOCerr = -1;
		//return m_XF.Run(nAutoUpdate, GetTree(), NULL, XVT_INT, &nOCerr, dwControl);
		TreeNode trGetN = GetTree();
		m_XF.InvokeBeforeExecute(trGetN, LTXF_XFBAR, -2); //-2 to indicate the call is from OC
		m_XF.SetGUI(trGetN);
		return m_XF.Evaluate();
		///---END FIX_CALL_XF_FROM_OC
	}
	return false;
	//------
}
*/
BOOL PageXFBar::callXF()
{
	return ( 0 == DoApply(GetTree()) );
}

///---Sim 02-29-2008 QA80-11156 SUPPORT_EXEC_VALUE_ON_DYNA_DLG
/*
//virtual
int PageXFBar::DoApply(TreeNode& trGetN)
{
	//int nErr = m_XF.Compile();
	//if(0 == nErr)
	{
		m_XF.InvokeBeforeExecute(trGetN, LTXF_XFBAR, -2); //-2 to indicate the call is from OC
		m_XF.SetGUI(trGetN);
		if ( m_XF.Evaluate() )
			return 0;
	}
	return -1; // error
}
*/
//virtual
int	PageXFBar::DoApply(TreeNode& trGetN)
{
	return ExecuteXF(m_XF, trGetN);
}
///---END QA80-11156 SUPPORT_EXEC_VALUE_ON_DYNA_DLG
//virtual
bool PageXFBar::CheckApplyButtonEvent(TreeNode& trGetN, int nEventID, int nEventReturn, LPCSTR lpcszAux, int* pnApplyReturn)// = NULL)
{
	int nApplyReturn;
	///---Sim 06-05-2008 FIX_NOT_STRICT_CODE
	if ( pnApplyReturn )
		nApplyReturn = *pnApplyReturn;
	///---END FIX_NOT_STRICT_CODE
	bool bRet = DynaDlg::CheckApplyButtonEvent(trGetN, nEventID, nEventReturn, lpcszAux, &nApplyReturn);
	if ( bRet ) // has done apply
	{
		bool bSuccessApplied = (0 == nApplyReturn);
		if ( !bSuccessApplied )
		{
			m_nFrameWorkState |= XFBAR_FRAME_WORK_FAILED_EXECUTE_XF;
		}
		else
		{
			///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
			//when no theme xf, should not save lastused theme
			//if(XFBAR_WIZARD_MODE != m_nMode)
			if(XFBAR_WIZARD_MODE != m_nMode && m_bThemeDlg)
			///End PAGEXFBAR_SUPPORT_NO_THEME_XF
				theme_update_last_used(m_trXF.XFName.strVal, GetTree());
			
			m_nFrameWorkState &= ~XFBAR_FRAME_WORK_FAILED_EXECUTE_XF;
			m_bApplied = true;
			m_bXFDone = true;
		}
	}
	
	if ( pnApplyReturn )
		*pnApplyReturn = nApplyReturn;
	return bRet;
}
///---END QA80-11156 XF_PANEL_APPLY_BUTTON

BOOL PageXFBar::OnApply(Control ctrl)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	if ( !m_applyBtn.Enable )
		return false;

	///---Sim 02-28-2008 QA80-11156 XF_PANEL_APPLY_BUTTON
	/*
	BOOL bRet = callXF();
	
	if ( !bRet )
	{
		m_nFrameWorkState |= XFBAR_FRAME_WORK_FAILED_EXECUTE_XF;
	}
	else
	{
		///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
		//when no theme xf, should not save lastused theme
		//if(XFBAR_WIZARD_MODE != m_nMode)
		if(XFBAR_WIZARD_MODE != m_nMode && m_bThemeDlg)
		///End PAGEXFBAR_SUPPORT_NO_THEME_XF
			theme_update_last_used(m_trXF.XFName.strVal, GetTree());
		
		m_nFrameWorkState &= ~XFBAR_FRAME_WORK_FAILED_EXECUTE_XF;
		m_bApplied = true;
		m_bXFDone = true;
	}
	*/
	///---END QA80-11156 XF_PANEL_APPLY_BUTTON
	
	invokeBasicGlobalEvent(GETNE_ON_APPLY);
	///---Sim 02-28-2008 QA80-11156 XF_PANEL_APPLY_BUTTON
	//return bRet;
	return (!(m_nFrameWorkState & XFBAR_FRAME_WORK_FAILED_EXECUTE_XF));
	///---END QA80-11156 XF_PANEL_APPLY_BUTTON
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
}
///---Sim 04-02-2007 ADD_UNDO_BUTTON
BOOL PageXFBar::OnUndo(Control ctrl)
{
	if ( m_bApplied && m_btnUndo.Enable )
	{
		invokeBasicGlobalEvent(GETNE_ON_UNDO);
		m_bApplied = false;
		m_bXFDone = false;
	}
	return true;
}
///---END ADD_UNDO_BUTTON

BOOL PageXFBar::OnClose(Control ctrl)
///---Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
{
	if ( XFBAR_WIZARD_MODE != m_nMode )
		OptionalMessage(STR_REMINDER_REOPEN_XFBAR, MB_OK);
	
	return Close();
}

bool PageXFBar::Close()
///---END v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
{
	///Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	if(m_bCloseDone)
		return TRUE;
	///End XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	
	///Joseph 02/07/07 FIX_BUG_ON_MORE_PAGES
	PostMessageOnObjectChange(false, m_wp);
	///End FIX_BUG_ON_MORE_PAGES
	invokeBasicGlobalEvent(GETNE_ON_CLOSE);   ///Joseph 10/13/06 Add destory event
	
	///---Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
	/*
	///Joseph 05/11/07 QA70-9744 ADD_REMAINDER_MESSAGE_ON_PAGEXFBAR_CLOSE
	//if ( XFBAR_WIZARD_MODE != m_nMode ) ///---Sim 08-02-2007 NOT_SHOW_HINT_MESSAGE_AS_NOT_SUPPORT_RIGHT_CLICK_TO_OPEN_XF_PANEL_ON_WIZARD_MODE
	if ( XFBAR_WIZARD_MODE != m_nMode && m_wp) ///Jasmine 09/05/08 CANNOT_REOPEN_XFBAR_IF_PAGE_IS_CLOSE
		OptionalMessage("ReOpenXFBar", MB_OK);
	///End ADD_REMAINDER_MESSAGE_ON_PAGEXFBAR_CLOSE
	*/
	///---END v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
	
	///Jasmine 08/28/08 QA80-12100 XF_IN_XFBAR_MAY_CLOSE_AFTER_PAGE_DESTROY
	if(m_wp && m_bKillOneself)	///Jasmine 08/28/08 XFBAR_NO_CLOSE_AGAIN_IF_IT_CLOSE_BY_OTHERS
	{
		/// Iris 06/29/2007 v8.0652 PFMWIZ_CLICK_FINISH_NOT_TO_CLOSE_XFBAR
		//LT_execute(";xfbar c");
		LT_set_str("strTempWinName$", m_wp.GetName());
		LT_execute(";win -o %(strTempWinName$) {xfbar c};del -vs strTempWinName");	
		///end PFMWIZ_CLICK_FINISH_NOT_TO_CLOSE_XFBAR
	}
	///End XF_IN_XFBAR_MAY_CLOSE_AFTER_PAGE_DESTROY
	
	m_bCloseDone = true;///Jasmine 08/27/08 QA80-12100 XFBAR_CLOSE_SHOULD_BEHAVIOUR_SAME_AS_CLOSE_BUTTON
	return true;
}


BOOL PageXFBar::OnAfterValueChange(int nRow, int nCol)
{
	///Joseph 04/23/07 FIX_BUG_ENABLE_BUTTONS_ON_CHANGE_GUI
	//don't need any more.
	//update gui and enable/disable button on value change should be in function OnRecontructGrid.
	//invokeBasicGlobalEvent(GETNE_ON_VALUE_CHANGE); ///Joseph 04/11/07 CHANGE_GUI_ON_VALUE_CHANGE
	///End FIX_BUG_ENABLE_BUTTONS_ON_CHANGE_GUI
	return FALSE;
}

BOOL PageXFBar::OnButtonClick(int n, int i)
{
	return callXF();
}

/*
//Redirect Selection related messages
BOOL PageXFBar::OnSelectionChange()
{
	return m_dynCntrl.OnSelectionChange();
}
BOOL PageXFBar::OnSelectionTrack()
{
	return m_dynCntrl.OnSelectionTrack();
}
//end --Redirect Selection related messages
*/

#define		MENU_CMDID_START	1
#define		_USGCNTEXT_SIZE		3		
#define		_WIN_TYPE_INDEX		0
// Returns the total count.
/// TD 3-14-06 QA70-8579 PAGE_NOT_ACTIVE_ON_SHOW
//static	int	_get_XFunctions_menu_tree(TreeNode &tr)
static	int	_get_XFunctions_menu_tree(TreeNode &tr, Page &pg)
/// end PAGE_NOT_ACTIVE_ON_SHOW
{
	//DWORD dwCtxts[6] = {IDXF_USGCTXT_LABTALK, IDXF_USGCTXT_MAIN_MENUS, IDXF_USGCTXT_LOGICAL_AND, 0, IDXF_USGCTXT_LOGICAL_AND, IDXF_USGCTXT_GETN_DLG};
	DWORD dwCtxts[_USGCNTEXT_SIZE] = {0, IDXF_USGCTXT_LOGICAL_AND, IDXF_USGCTXT_GETN_DLG};
	/// TD 3-14-06 QA70-8579 SAVE_XFUNCTION_INFO_IN_PAGE
	//Page pg = Project.Pages();
	/// end SAVE_XFUNCTION_INFO_IN_PAGE
	switch(pg.GetType())
	{
	case EXIST_WKS:
		dwCtxts[_WIN_TYPE_INDEX] = IDXF_USGCTXT_WINDOW_WKS;
		break;
	case EXIST_PLOT:
		dwCtxts[_WIN_TYPE_INDEX] = IDXF_USGCTXT_WINDOW_GRAPH;
		break;
	case EXIST_MATRIX:
		dwCtxts[_WIN_TYPE_INDEX] = IDXF_USGCTXT_WINDOW_MATRIX;
		break;
	default:
		return FALSE;// not supported
	}
	int			nn = okutil_make_tree_from_map(&tr, MENU_CMDID_START, SUPPORTFILE_XF, FF_REMOVE_PATH | FF_REMOVE_CATEGORY | FF_ADD_DESCRIPTION, dwCtxts, _USGCNTEXT_SIZE);
	return 0 < nn;
}


///////////////
//
///////////////
class	PageXFBarChooserAction : public ActionBase
{
public:
	// virtual
	bool BuildMenuTree(TreeNode &tr)
	{
		/// TD 3-14-06 QA70-8579 SAVE_XFUNCTION_INFO_IN_PAGE
		//return 0 < _get_XFunctions_menu_tree(tr);
		Page pg = Project.Pages();
		return 0 < _get_XFunctions_menu_tree(tr, pg);
		/// end SAVE_XFUNCTION_INFO_IN_PAGE
	}
	
	// virtual
	bool HandleCommand(int nCmdId, TreeNode &trCmd)
	{
		GETN_AMENU_GET_TEXT(m_strXFnChosen, trCmd);
		return true;
	}
	
	
	string			GetXFnName()
	{
		return m_strXFnChosen;
	}
	
private:
	string			m_strXFnChosen;
};


// Returns TRUE if a function chosen.
// If lpcszDefault is NULL, no XF will be loaded
// if lpcszDefault is "", it will just get the first one.
// if lpcszDefault is an XF name, it will be loaded and chooser GUI will be hidden
BOOL	PageXFBar::functionChooser(string &strXF, LPCSTR lpcszDefault, bool bSetShowChooser)
{
	if ( lpcszDefault )			
	{
		if(*lpcszDefault == '\0')// just get the first you find
		{
			Tree			tr;
			if(bSetShowChooser)
				///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
				//m_bShowChooser = true;
				m_nMode = XFBAR_CHOOSER_MODE;
				///End ADD_CHOOSE_INDEP_WIZARD_MODE
			Page pg = Project.Pages(); //CPY 3/30/05
			if (pg && _get_XFunctions_menu_tree(tr, pg))
			{
				TreeNode		trFunc;
				if ( !octree_find_node_by_dataID(&trFunc, &tr, MENU_CMDID_START) )
				{
					ASSERT(FALSE);
					return FALSE;		// no functions at all?
				}
			
				GETN_AMENU_GET_TEXT(strXF, trFunc);
				
				return TRUE;
			}
		}
		else // XF is specified
		{
			strXF = lpcszDefault;
			///Joseph 10/12/06 it should not show the function_chooser when there are no xfuctinos;
			//if(bSetShowChooser)
				//m_bShowChooser = false;
			//return true;
			///End it should not show the function_chooser when there are no xfuctinos;
			return TRUE; 
		}
		return FALSE;		// no functions?
	}
	
	HWND					hWnd = m_btnChooser.GetSafeHwnd();
	RECT					rect;
	m_btnChooser.GetWindowRect(&rect);
	
	
	PageXFBarChooserAction	act;
	MenuAction				ma(act);
	if ( ma.DoMenu(0, rect.right, rect.top, hWnd) < 0 )
		return FALSE;

	strXF = act.GetXFnName();
	if ( strXF.IsEmpty() )
		return FALSE;		// nothing chosen
	
	return TRUE;
}

///Joseph Sim	04/04/07 IMPROVE_MULTI_THEME_FRAME_WORK
bool	PageXFBar::setDefautlValuetoGetNTree(TreeNode& trGetN)
{
	if(!trGetN)
		return false;
	
	TreeNode trTemp;
	//----- CPY 5/7/2007 PAGE_XFBAR_SHOW_RECALCULATE_ALWAYS_NEED_GENERAL_XF_TO_GETN_CLEANUP
	//initGetNTree(trTemp);
	Tree trGetNTempRoot;
	m_XF.GetGUI(trGetNTempRoot, trTemp);
	//-----
	tree_copy_values_by_id(trTemp, trGetN);
	return true;
}
///End IMPROVE_MULTI_THEME_FRAME_WORK

///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
/*
BOOL PageXFBar::OnSaveTheme(Control ctrl)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
	updateCurrentTheme(); // to theme
	
	TreeNode trGetN = GetTree();
	
	//Tree trClass;
	//switch(m_nMode)
	//{
	//case XFBAR_INDEP_MODE:
		//trClass = trGetN;
		//break;
	//case XFBAR_WIZARD_MODE:
		//trClass = m_trCurrentThemes.FirstNode;
		//break;
	//default:
		//return true;
		//break;
	//}	

	//string strThemeFilename;
	//if ( m_comboTheme.GetCurSel() > 0 )
	//{
		//string strSel;
		//m_comboTheme.GetLBText(m_comboTheme.GetCurSel(), strSel);
		//
		//string strClassOption;
		//theme_get_class_option(trClass, strClassOption);
		//
		//strThemeFilename = theme_get_settings_file(strSel, strClassOption, tree_get_theme_type(trClass));
	//}
	//if(strThemeFilename.IsEmpty())
	//{
		////strThemeFilename = STR_LAST_USED;
		//return false;
	//}

	BOOL bRet = false;
	switch(m_nMode)
	{
	case XFBAR_INDEP_MODE:
		bRet = theme_save_settings(trGetN);
		break;
	case XFBAR_WIZARD_MODE:
		bRet = themes_tree_to_file(m_trCurrentThemes);
		break;
	default:
		break;
	}	

	//return theme_save_settings(tr);	
	return bRet;
	///---END IMPROVE_MULTI_THEME_FRAME_WORK	
}
BOOL PageXFBar::OnSaveAsTheme(Control ctrl)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
	updateCurrentTheme(); // to theme
	
	TreeNode trGetN = GetTree();
	
	Tree trClass;
	switch(m_nMode)
	{
	case XFBAR_INDEP_MODE:
		trClass = trGetN;
		break;
	case XFBAR_WIZARD_MODE:
		trClass = m_trCurrentThemes.FirstNode;
		break;
	default:
		return true;
		break;
	}	

	string strFullFileName;
	strFullFileName = theme_ask_save_as_filename(trClass, GetSafeHwnd());
	if(strFullFileName.IsEmpty())
		return	true;
	
	if ( XFBAR_INDEP_MODE == m_nMode )
	{
		if ( !theme_save_settings(trGetN, strFullFileName) )
			return false
	}
	else
	{
		if ( !themes_tree_to_file(m_trCurrentThemes, strFullFileName) )
			return false;
	}
	
	loadThemeFilesToCombo(trClass);
	///---END IMPROVE_MULTI_THEME_FRAME_WORK	
	return true;
}
*/

///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
//virtual BOOL PageXFBar::SaveTheme(TreeNode& trGetN, LPCSTR lpcszFilename)// = NULL)
virtual BOOL PageXFBar::SaveTheme(TreeNode& trGetN, LPCSTR lpcszThemeName)
///---END CLEAR_THEME_SAVE_METHOD
{
	BOOL bRet = false;
		
	///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
	string strClassOption;
	theme_get_class_option(trGetN, strClassOption);	

	//------ Folger 07/11/08 FIX_SAVE_DEFAULT_THEME_IN_PAGE_XF_BAR
	///---Sim 09-05-2008 CLEAN_DEFAULT_THEME
	//if ( okutil_cvt_str_to_predefined_type(lpcszThemeName) == PDS_DEFAULT )
	if ( is_theme_default(lpcszThemeName) )
	///---END CLEAN_DEFAULT_THEME
	{
		return theme_default_setting_management(trGetN, THEME_DEFAULT_SET);
	}
	//------
	
	string strFileName = theme_get_settings_file(lpcszThemeName, strClassOption);
	///---END CLEAR_THEME_SAVE_METHOD
	
	switch(m_nMode)
	{
	case XFBAR_INDEP_MODE:
		///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
		//bRet = theme_save_settings(trGetN, lpcszFilename);
		bRet = theme_save_settings(trGetN, strFileName);
		///---END CLEAR_THEME_SAVE_METHOD
		break;
	case XFBAR_WIZARD_MODE:
		//string strFileName = lpcszFilename;
		updateCurrentTheme(); // current getn to theme tree
		///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
		//bRet = themes_tree_to_file(m_trCurrentThemes, lpcszFilename);
		bRet = themes_tree_to_file(m_trCurrentThemes, strFileName);
		///---END CLEAR_THEME_SAVE_METHOD
		break;
	}	

	return bRet;
}
///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
//virtual BOOL PageXFBar::LoadTheme(TreeNode& trGetN, string strTheme)
virtual BOOL PageXFBar::LoadTheme(TreeNode& trGetN, LPCSTR lpcszThemeName)
///---END CLEAR_THEME_SAVE_METHOD
{
	string strTheme = lpcszThemeName;///---Sim 07-03-2008 CLEAR_THEME_SAVE_METHOD
	
	//return theme_update_on_new_sel(trGetN, strTheme);
	
	BOOL bRet = false;
	
	///Joseph 05/11/07 SHOULD_LOAD_USER_FOLDER_THEME
	if(0 == strTheme.Compare(STR_LAST_USED))
		strTheme = strTheme.Mid(1, strTheme.GetLength() - 2);  // <last used> remove <>
	///End SHOULD_LOAD_USER_FOLDER_THEME
	
	switch(m_nMode)
	{
	case XFBAR_INDEP_MODE:
		/// Hong 12/17/08 QA80-12798 THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES
		//bRet = theme_update_on_new_sel(trGetN, strTheme);
		bRet = DynaDlg::LoadTheme(trGetN, strTheme);
		/// end THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES
		break;
	case XFBAR_WIZARD_MODE:
		string strClassOption;
		theme_get_class_option(trGetN, strClassOption);
		
		///Joseph 05/11/07 SHOULD_LOAD_USER_FOLDER_THEME
		//string strThemeFilename = theme_get_settings_file(strTheme, strClassOption, tree_get_theme_type(trGetN));
		string strThemeFilename = okutil_theme_construct_filename(strTheme, tree_get_theme_type(trGetN), ORIGIN_PATH_USER, 0, strClassOption);
		///End SHOULD_LOAD_USER_FOLDER_THEME
		
		if(strThemeFilename.IsEmpty())	//Factory Default
		{
			///---Sim 06-30-2007 FIX_FACTORY_DEFAULT_THEME_APPIED_ISSUE
			//tree_set_theme_file_name(trGetN, NULL);
			//tree_set_theme_file_name(m_trCurrentThemes, NULL);
			tree_set_theme_file_name(trGetN, STR_THEME_NONE);
			tree_set_theme_file_name(m_trCurrentThemes, STR_THEME_NONE);
			///---END FIX_FACTORY_DEFAULT_THEME_APPIED_ISSUE
		}
		else
		{
			tree_set_theme_file_name(trGetN, strThemeFilename);
			tree_set_theme_file_name(m_trCurrentThemes, strThemeFilename);
		}
		///---Sim 09-05-2008 CLEAN_DEFAULT_THEME
		/////Sohy 4/25/08 ROW_STATS_PUT_RESULTS_COL_TO_BEGINNING_OF_SRC_SHEET
		////int nType = cvt_str_to_predefined_type(strTheme);
		//int nType = str_to_predefined_type(strTheme);
		/////end ROW_STATS_PUT_RESULTS_COL_TO_BEGINNING_OF_SRC_SHEET
		//if( PDS_FACTORY_DEFAULT == nType )
		if ( theme_is_factory_default(strTheme) )
		///---END CLEAN_DEFAULT_THEME
		{
			//m_trCurrentThemes.Reset(); // clear exist theme tree
			initThemeTree(m_trCurrentThemes);
			bRet = true;
		}
		else
			bRet = themes_tree_from_file(m_trCurrentThemes);//, strThemeFilename);
		
		if ( bRet )
		 	updateCurrentTheme(true); // update to current getn
		break;
	}	

	return bRet;
}
///---END IMPROVE_MULTI_THEME_FRAME_WORK

/// Hong 12/17/08 QA80-12798 THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES
//virtual
BOOL 	PageXFBar::CompareTheme(const TreeNode& trGetN, LPCSTR lpcszThemeName, TreeNode& trDiff)
{
	if ( XFBAR_INDEP_MODE != m_nMode )
	{
		ASSERT(FALSE); // DO NOT support wizard mode anymore
		return FALSE;
	}
	
	return DynaDlg::CompareTheme(trGetN, lpcszThemeName, trDiff);
}
/// end THEME_COMPARING_WITH_GUI_SETTING_NEED_FOR_QUICK_CATCH_OF_CHANGES

///Joseph 10/10/06	 ADD_CHOOSE_INDEP_WIZARD_MODE
///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
//bool PageXFBar::checkOptionalXFClicked()
//{
	//Control ctrl1,ctrl2,ctrl3;
	/////Joseph 02/26/07  USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON
	////ctrl1 = GetItem(IDC_BTN_XFUN1);
	////ctrl2 = GetItem(IDC_BTN_XFUN2);
	////ctrl3 = GetItem(IDC_BTN_XFUN3);
	//ctrl1 = GetItem(IDC_GETN_CUSTOM_BTN1);
	//ctrl2 = GetItem(IDC_GETN_CUSTOM_BTN2);
	//ctrl3 = GetItem(IDC_GETN_CUSTOM_BTN3);
	/////End USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON
	//if(ctrl1.Enable && ctrl2.Enable && ctrl3.Enable)
		//return false;
	//return true;
//}
///---END IMPROVE_MULTI_THEME_FRAME_WORK	

///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
/*
void PageXFBar::beforeNextUpdateThemeTree(string strLabel)
{
	TreeNode trNode;
	TreeNode tr;
	tr = GetTree();
	///Joseph 02/28/07	XF_WIZ_CLEANUP
	//if(!checkOptionalXFClicked())
	//{
		//trNode = tree_check_get_node(m_trCurrentTheme, strLabel);
		//trNode.Replace(tr, true, true);
	//}
	//TreeNode trTemp = m_trCurrentThemes.GetNode(strLabel);
 	//if(! trTemp )
	//{
	///End XF_WIZ_CLEANUP
	trNode = tree_check_get_node(m_trCurrentThemes, strLabel);
	trNode.Replace(tr, true, true);
	///Joseph 02/28/07	XF_WIZ_CLEANUP
	//}
	//else
		//tree_copy_values(tr, trTemp);
	///End XF_WIZ_CLEANUP
}

bool PageXFBar::beforPreviousUpdateThemeTree(string strLabel)
{
	TreeNode trNode;
	TreeNode tr;
	tr = GetTree();
	///Joseph 02/28/07	XF_WIZ_CLEANUP
	//TreeNode trTemp;
	//trTemp = tr.Clone();
	//string strNowLabel;
	//if(! changeLabelToXFName(m_XF, strNowLabel))
		//return false;
	///End XF_WIZ_CLEANUP
	
	trNode = tree_check_get_node(m_trCurrentThemes, strLabel);
	if(trNode)
	{
		m_trCurrentThemes.RemoveChild(strLabel);
	}
	///Joseph 02/28/07	XF_WIZ_CLEANUP
	//trNode = tree_check_get_node(m_trCurrentTheme, strLabel);
	
	//if(trNode)
	//{
		//m_trCurrentTheme.RemoveChild(strLabel);
	//}
//
	//if(! strNowLabel.Compare(strLabel))
		//trNode.Replace(trTemp, true, true);
	//else
		//tr.Replace( trNode , false, true);
	///End XF_WIZ_CLEANUP
	return true;
}
*/
bool PageXFBar::updateThemeTree(TreeNode& trThemeGroup, string strLabel, TreeNode trGetN, bool bToGetN)// = false
{
	//TreeNode trNode = tree_check_get_node(trThemeGroup, strLabel);
	TreeNode trTheme = trThemeGroup.FindNodeByAttribute(STR_XF_NAME_ATTRIB, strLabel);
	
	if ( bToGetN ) // load theme to getn
	{
		if ( !trTheme )
		{	// default setting
			///Joseph Sim	04/04/07 IMPROVE_MULTI_THEME_FRAME_WORK
			//initGetNTree(trGetN); // initialize current xfuntion getn GUI
			setDefautlValuetoGetNTree(trGetN);
			///End IMPROVE_MULTI_THEME_FRAME_WORK
			if ( !m_strClassOption.IsEmpty() )
				theme_set_class_option(trGetN, m_strClassOption);
		}
		else
		{
			//trGetN.Replace(trTheme, true, true);
			theme_tree_to_getn_tree(trTheme, trGetN, m_bRestoreXFMode); // keep up runtime getn info when go to previous xf,
																		// m_bRestoreXFMode is a flag for is it previous or next.
		}
	}
	else // save getn to theme
	{
		if ( !trTheme )
		{
			string strValidTag = strLabel;
			strValidTag.MakeValidCName('_');
			trTheme = tree_check_get_node(trThemeGroup, strValidTag);
			trTheme.SetAttribute(STR_XF_NAME_ATTRIB, strLabel);
		}
		//trTheme.Replace(trGetN, true, true);
		theme_tree_from_getn_tree(trTheme, trGetN, true); // always save runtime info to theme tree.
	}
	
	return true;
}

bool PageXFBar::updateCurrentTheme(bool bToGetN)// = false
{
	string strXFName;
	if ( !getCurXF(strXFName) )
	{
		out_str(_L("Error. Current XFunction page is invalid!"));
		return false;
	}
	
	TreeNode trGetN = GetTree();
	if ( !trGetN )
		return false;
	
	return updateThemeTree(m_trCurrentThemes, strXFName, trGetN, bToGetN);
}
///---END IMPROVE_MULTI_THEME_FRAME_WORK
///End ADD_CHOOSE_INDEP_WIZARD_MODE

///Joseph 10/13/06 QA70-9039 XF_WIZARD_BAR
BOOL PageXFBar::OnPrevious(Control ctrl)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	updateCurrentTheme();
	//if ( m_bApplied )
		//invokeBasicGlobalEvent(GETNE_ON_UNDO); // undo current xfunction
	//if ( !m_bRepeatingApply )
	OnUndo(ctrl);
	
	m_bRestoreXFMode = true; // change to restore initial mode
	invokeBasicGlobalEvent(GETNE_ON_PREVIOUS);
	m_bRestoreXFMode = false;
	
	//m_bApplied = true;
	
	/*
	if(m_nWizStep == 0)
	{
		out_str("OnPrevious reached begin, cannot go back more");
		return true;
	}
	
	// process current xfunction page
	updateCurrentTheme();
	invokeBasicGlobalEvent(GETNE_ON_UNDO); // undo current xfunction
	
	// process previous xfunction page
	string strXFName;
	if(!getPrevXF(strXFName))
	{
		out_str("Error. OnPrevious when no XF to go previous!");
		return true;
	}
	checkRemoveAfterCurXFs();
	
	setControl(strXFName, true);
	//invokeBasicGlobalEvent(GETNE_ON_UNDO); // undo previous xfunction
	
	m_comboTheme.Enable = m_nWizStep?false:true;
	//m_applyBtn.Enable = true;
	*/
	///---END IMPROVE_MULTI_THEME_FRAME_WORK

	return true;
}

BOOL PageXFBar::OnNext(Control ctrl)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	//updateCurrentTheme();	/// Iris 07/25/2007 FIX_FAIL_TO_SAVE_THEME_WHEN_CLICK_FINISH_IN_PFMWIZ
	if ( !m_bXFDone )
		OnApply(ctrl);
	updateCurrentTheme();	/// Iris 07/25/2007 FIX_FAIL_TO_SAVE_THEME_WHEN_CLICK_FINISH_IN_PFMWIZ
		
	///---Sim 04-16-2007 MAKE_SURE_THE_ATTACHED_PAGE_BE_ACTIVE
	page_set_active_layer(m_wp, m_wp.Layers().GetIndex());
	///---END MAKE_SURE_THE_ATTACHED_PAGE_BE_ACTIVE
	
	if ( XFBAR_FRAME_WORK_NORMAL == m_nFrameWorkState )
	{
		//m_bEnableAutoApply = false; // close auto apply for prevent error in event function
		invokeBasicGlobalEvent(GETNE_ON_NEXT);
		//m_bEnableAutoApply = true;
		
		m_bApplied = false;
		
		if ( m_chkAutoApply.Visible && m_chkAutoApply.Check )
		{
			Control ctrl;
			OnApply(ctrl);
		}			
	}
	else
		error_report(_L("Failed to execute current xf, not go to next xf!"));
	/*
	string strXF;
	if(!getNextXF(strXF, false))
	{
		out_str("Error. OnNext when no XF to go next!");
		return true;
	}	
	
	// current xf page
	OnApply(ctrl);	
	updateCurrentTheme();
	
	// next xf page
	if(!getNextXF(strXF))
	{
		out_str("Error. OnNext when no XF to go next!");
		return true;
	}	
	
	setControl(strXF, true);
	OnApply(ctrl); // apply firstly
	
	m_comboTheme.Enable = false;
	*/
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	return true;
}
	
BOOL PageXFBar::OnFinish(Control ctrl)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	m_bClickFinished =  true; // this a flag for not update GUI
	while ( m_btnNext.Enable )
		OnNext(ctrl);
	
	// for last page
	//updateCurrentTheme();  /// Iris 07/25/2007 FIX_FAIL_TO_SAVE_THEME_WHEN_CLICK_FINISH_IN_PFMWIZ
	OnApply(ctrl);	
	
	//invokeBasicGlobalEvent(GETNE_ON_FINISH); ///---Sim 07-23-2007 INVOKE_FINISH_EVENT_FOR_XFBAR_WIZARD
	/*
	updateCurrentTheme();
	
	//if apply already, then skip; else apply first
	//if(m_applyBtn.Enable)
	//{
	OnApply(ctrl);
	//}
	m_bClickFinished =  true; // this a flag for not update GUI
	
	//invokeBasicGlobalEvent(GETNE_ON_FINISH);
	invokeBasicGlobalEvent(GETNE_ON_NEXT);
	
	string strXFName;
	if ( !getNextXF(strXFName) )
		strXFName.Empty();
	
	//while(!m_strXFList.IsEmpty())
	while(!strXFName.IsEmpty())
	{
		//setControl(m_strXFList, false);
		if ( !setControl(strXFName, false) )
			break;
		//Control ctrl;
		OnApply(ctrl);
		updateCurrentTheme();

		//invokeBasicGlobalEvent(GETNE_ON_FINISH);
		invokeBasicGlobalEvent(GETNE_ON_NEXT);
		if ( !getNextXF(strXFName) )
			break;
		//if(m_strXFList.IsEmpty())
			//invokeBasicGlobalEvent(GETNE_ON_CLOSE);		
	}
	*/
	updateCurrentTheme(); /// Iris 07/25/2007 FIX_FAIL_TO_SAVE_THEME_WHEN_CLICK_FINISH_IN_PFMWIZ, OnApply might change trGetN, so should get theme tree after do Apply.
	if(m_bThemeDlg)		///Joseph 05/17/07 PAGEXFBAR_SUPPORT_NO_THEME_XF
		themes_update_last_used(m_strClassOption, m_trCurrentThemes);
	
	//invokeBasicGlobalEvent(GETNE_ON_CLOSE);
	//LT_execute(";xfbar c");
	///---Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
	//OnClose(ctrl);
	Close();
	///---END v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	return false;
}
///End QA70-9039 XF_WIZARD_BAR

///Joseph	12/07/06	ADD_MESSAGE_BOX
void PageXFBar::ResizeDlgControls()
{
	OnDlgResize(0, GetDlgExtent(false), GetDlgExtent(true));
}
///Joseph 02/25/06 DO_NOT_ENABLE_BUTTON_ON_SOME_EVENTS
//void PageXFBar::OnEnableButtons(DWORD dwEnable)
void PageXFBar::OnEnableButtons(DWORD dwEnable, int nEventID)
///End DO_NOT_ENABLE_BUTTON_ON_SOME_EVENTS
{
	bool bOKEnable = (dwEnable & GETNGEVT_OK_ENABLE); // this code only work when place here

	///---Sim 03-28-2007 ADDITIONAL_GETN_EVENT
	if ( IS_NO_ACTION_GETN_EVENT(nEventID) )
		return; // not change button
	///---END ADDITIONAL_GETN_EVENT
	
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
//	int buf[10] = {0,1,2,3,4,5,6,7,8,9};
//	bool bOKEnable2 = (dwEnable & GETNGEVT_OK_ENABLE); //CP will check later if using this line will lead to value changed after calling invoke
//	int buf2[10] = {0,1,2,3,4,5,6,7,8,9};
//	out_int("Enable before", bOKEnable2);

//
	//if ( m_bRepeatingApply || !m_bApplied ) 
	//{
		//m_applyBtn.Enable = bOKEnable;
	//}
	//
	///Joseph 02/25/06 DO_NOT_ENABLE_BUTTON_ON_SOME_EVENTS
	//EnableCustomButtons(dwEnable);  ///Joseph 02/26/07  USEING_CUSTOM_BUTTON_REPLACE_OPTIONAL_BUTTON
	
	switch(nEventID)
	{
	case GETNE_ON_INIT_XFWIZ:
		m_btnPrev.Enable = false;
		
		string strXF;
		invokeBasicGlobalEvent(GETNE_GET_NEXT);
		//out_int("Enable after invoke ", bOKEnable2);
		m_btnNext.Enable = getNextXF(strXF, false);
		checkRemoveAfterCurXFs();

		// keep context of xfs
		m_bHasPrevXF = m_btnPrev.Enable;
		m_bHasNextXF = m_btnNext.Enable;
		
		m_applyBtn.Enable = bOKEnable;
		m_btnUndo.Enable = false;
		
		if ( m_bEnableAutoApply && m_chkAutoApply.Visible && m_chkAutoApply.Check )
		{
			Control ctrl;
			OnApply(ctrl);
		}
		break;
		
	case GETNE_ON_INIT:
		if ( m_bApplied )
			m_btnUndo.Enable = true;
		else
			m_btnUndo.Enable = false;
		EnableCustomButtons(dwEnable);
	case GETNE_ON_THEME:	///---Sim 08-31-2007 THEME_CHANGE_SHOULD_CAUSE_APPLY_AGAIN
	case GETNE_ON_VALUE_CHANGE:
		if ( m_bRepeatingApply || !m_bApplied ) 
		{
			m_applyBtn.Enable = bOKEnable;
		}	
		EnableCustomButtons(dwEnable);		
		
		if ( bOKEnable )
			m_nFrameWorkState &= ~XFBAR_FRAME_WORK_XF_NO_READY;
		else
			m_nFrameWorkState |= XFBAR_FRAME_WORK_XF_NO_READY;
		
		m_bXFDone = false;
		
		if ( m_bEnableAutoApply && m_chkAutoApply.Visible && m_chkAutoApply.Check )
		{
			Control ctrl;
			OnApply(ctrl);
		}		
		break;
	case GETNE_ON_RESTORE:
				if ( m_bApplied )
		{
			m_applyBtn.Enable = false; // previous xfunction should be applied.
			m_btnUndo.Enable = true;
		}
		else
		{
			m_applyBtn.Enable = bOKEnable;
			m_btnUndo.Enable = false;
		}
		
		EnableCustomButtons(dwEnable);
		
		if ( bOKEnable )
			m_nFrameWorkState &= ~XFBAR_FRAME_WORK_XF_NO_READY;
		else
			m_nFrameWorkState |= XFBAR_FRAME_WORK_XF_NO_READY;
		
		m_bXFDone = true;	
		break;
	case GETNE_ON_PREVIOUS:
		string strXF;
		m_btnPrev.Enable = getPrevXF(strXF, false);
		
		m_btnNext.Enable = true;
		
		m_comboTheme.Enable = (m_btnPrev.Enable) ? false : true;
		
		///Sim 04/12/07 FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1
		//if ( m_bRepeatingApply )
			//m_applyBtn.Enable = true;
		///End FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1
			
		//m_applyBtn.Enable = false; // previous xfunction should be applied.
		//m_btnUndo.Enable = true;
		
		// keep context of xfs
		m_bHasPrevXF = m_btnPrev.Enable;
		m_bHasNextXF = m_btnNext.Enable;
		break;
	case GETNE_ON_NEXT:
		m_btnPrev.Enable = true;
				
		invokeBasicGlobalEvent(GETNE_GET_NEXT);
		string strXF;
		m_btnNext.Enable = getNextXF(strXF, false);
		checkRemoveAfterCurXFs();
		
		m_comboTheme.Enable = false;
		
		//m_applyBtn.Enable = bOKEnable; // according to current xfunction setting, apply button has be set on initial event
		//m_btnUndo.Enable = false;
		
		// keep context of xfs
		m_bHasPrevXF = m_btnPrev.Enable;
		m_bHasNextXF = m_btnNext.Enable;
		break;
	case GETNE_ON_APPLY:
		if ( m_bApplied )
		{
			if ( !m_bRepeatingApply ) // apply only one times
				m_applyBtn.Enable = false;
			else
				m_applyBtn.Enable = bOKEnable;
			
			m_btnUndo.Enable = true;
			
			//on apply, enable/disable the custom button
			EnableCustomButtons(dwEnable);	///Joseph 04/12/07 FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1
		}
		break;
	case GETNE_ON_UNDO:
		m_applyBtn.Enable = bOKEnable;
		m_btnUndo.Enable = false;
		EnableCustomButtons(dwEnable);
		break;
	default:
		if ( m_bRepeatingApply || !m_bApplied ) 
		{
			m_applyBtn.Enable = bOKEnable;
		}
		
		if ( m_bApplied )
			m_btnUndo.Enable = true;
		else
			m_btnUndo.Enable = false;
		
		///---Sim 05-11-2007 FIX_WIZARD_BUTTON_CONTROL
		if ( bOKEnable )
			m_nFrameWorkState &= ~XFBAR_FRAME_WORK_XF_NO_READY;
		else
			m_nFrameWorkState |= XFBAR_FRAME_WORK_XF_NO_READY;
		///---END FIX_WIZARD_BUTTON_CONTROL
		
		EnableCustomButtons(dwEnable);
		break;
	}

	///---Sim 05-11-2007 CLEAR_NO_USED_CODE
	/*
	if ( GETNE_ON_INIT_XFWIZ == nEventID )
	{
		m_btnPrev.Enable = false;
		
		string strXF;
		invokeBasicGlobalEvent(GETNE_GET_NEXT);
		//out_int("Enable after invoke ", bOKEnable2);
		m_btnNext.Enable = getNextXF(strXF, false);
		checkRemoveAfterCurXFs();

		// keep context of xfs
		m_bHasPrevXF = m_btnPrev.Enable;
		m_bHasNextXF = m_btnNext.Enable;
		
		m_applyBtn.Enable = bOKEnable;
		m_btnUndo.Enable = false;
		
		if ( m_bEnableAutoApply && m_chkAutoApply.Visible && m_chkAutoApply.Check )
		{
			Control ctrl;
			OnApply(ctrl);
		}			
	}
	*/
	///---END CLEAR_NO_USED_CODE
	
	// for all event
	if ( XFBAR_FRAME_WORK_NORMAL != m_nFrameWorkState )
	{
		m_btnNext.Enable = false; // disallow go to next
		m_btnFinish.Enable = false;
	}
	else
	{
		m_btnNext.Enable = m_bHasNextXF; // allow go to next
		m_btnFinish.Enable = true;
	}
	
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
}
///End	ADD_MESSAGE_BOX
///Joseph 12/25/06  FIX_BUG_ON_SAVE_THEME
void 	PageXFBar::InvokeGlobalEventOnThemeChange()
{
	invokeBasicGlobalEvent(GETNE_ON_THEME);
}
///End FIX_BUG_ON_SAVE_THEME
///Joseph 02/25/07 DISABLE_BUTTON_BEFORE_APPLY
//void PageXFBar::enableOptionalButton()
//{
	//Control ctrl = GetItem(IDC_BTN_XFUN1);
	//ctrl.Enable = true;
	//ctrl = GetItem(IDC_BTN_XFUN2);
	//ctrl.Enable = true;
	//ctrl = GetItem(IDC_BTN_XFUN3);
	//ctrl.Enable = true;
//}
//----CPY 2/26/2007 XF_WIZ_CLEANUP
/*
void PageXFBar::enableOptionalButtons(bool bEnable)
{
	
	Control ctrl = GetItem(IDC_GETN_CUSTOM_BTN1);
	ctrl.Enable = bEnable;
	ctrl = GetItem(IDC_GETN_CUSTOM_BTN2);
	ctrl.Enable = bEnable;
	ctrl = GetItem(IDC_GETN_CUSTOM_BTN3);
	ctrl.Enable = bEnable;
}
*/
///End DISABLE_BUTTON_BEFORE_APPLY
///Joseph 01/28/07 CHANGE_XF_APPLY_BUTTON_TEXT
void PageXFBar::OnInitChangeButtonText(LPCSTR lpcszText)
{
	if(m_applyBtn)
		m_applyBtn.Text = lpcszText;
}	
///End CHANGE_XF_APPLY_BUTTON_TEXT

//----------- CPY 2/19/07 CUSTOM_APPLY_BUTTONS_CLEANUP
/*
///Joseph 02/14/07 SUPPORT_MORE_SPECAIL_EVENT
bool PageXFBar::IsSpecialEvent(int nEventID)
{
	if(nEventID >= GETNE_ON_PREVIOUS && nEventID <= GETNE_ON_FINISH)
		return true;
	return false;
}
void PageXFBar::OnSpecialButtons(int nEventID, const string& strAux)
{
	TreeNode trNode = GetTree();
	if(GETNE_ON_FINISH == nEventID)
		return; // later
	
	string strXFName;
	if(!strAux.IsEmpty())
	{ 
		///Joseph 10/13/06 QA70-9039 XF_WIZARD_BAR
		if(GETNE_ON_NEXT == nEventID || GETNE_ON_PREVIOUS == nEventID)
		{
			m_strOptionalFun = "";
			enableOptionalButton();
			
		}
		
		int nIndex = strAux.Find("|");
		if(nIndex > 0)
		{
			strXFName = strAux.Left(nIndex);
			strAux.TrimLeft(strXFName + "|");
			m_strOptionalFun = strAux;
			strXFName.TrimRight();
		}
		else
			strXFName = strAux;
		setFunction(strXFName, false);
		//setFunction(strAux, false);
		///End XF_WIZARD_BAR
	}
}
*/

///Joseph 06/06/07 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
//on next, we should remove the static vector value;
//on previous,
void PageXFBar::postGraphObjectMessageOnWizMode(bool bCreate)
{
	TreeNode trGUI = GetTree();
	int nVal;
	if(trGUI && trGUI.GetAttribute(STR_ATTRIB_POST_USER_MESSAGE, nVal))
	{
		PostMessageOnObjectChange(bCreate, m_wp);
	}	
}
///End FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE

bool PageXFBar::CheckCustomBottonEvents(int nEventID, int nEventRet, const string& strAux)
{
	///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK
	if ( m_nMode != XFBAR_WIZARD_MODE )
	{
		DynaDlg::CheckCustomBottonEvents(nEventID, nEventRet, strAux); ///---Sim 10-31-2008 INDICATE_THEME_ON_PA_FIT_PARAM_CHANGE
		//on click apply and close, close the dlg.
		if(GETNE_ON_APPLY == nEventID && PEVENT_GETN_RET_TO_CLOSE == nEventRet) 
		{
			///---Sim 10-27-2008 v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
			//Control ctrl;
			//OnClose(ctrl);
			Close();
			///---END v8.961 QA80-12463-P1-P2 SHOW_REOPEN_REMINDER_MESSAGE_ONLY_WHEN_USER_FORCELY_CLOSE_IT
			return true;
		}
	}
	else
	{
		if ( GETNE_GET_NEXT == nEventID )///---Sim 03-28-2007 ADDITIONAL_GETN_EVENT
		{
			checkAddNext(strAux);
		}
		if ( GETNE_ON_NEXT == nEventID ) // go to next xf
		{
			///---Sim 07-04-2007 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
			//postGraphObjectMessageOnWizMode(false);	///Joseph 06/06/07 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE 
			///---END FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
			
			if ( !checkAddNext(strAux) )
			{
				out_str("Error. Not next xfunction. It is end of xfunction wizard!");
				return true;
			}

			//Control ctrl; // not usefull, just for pass parameter to event function
			
			// current xf page
			//updateCurrentTheme();
			//OnApply(ctrl);
			
			// next xf page
			string strXFName;
			if(!getNextXF(strXFName))
			{
				out_str("Error. OnNext when no XF to go next!");
				return true;
			}	
			
			m_bApplied = false;
			setControl(strXFName, true);
			//OnApply(ctrl); // apply firstly
		}
		
		
		
		if ( GETNE_ON_PREVIOUS == nEventID ) // go to previous xf
		{
			string strXFName;
			if(!getPrevXF(strXFName, false))
			{
				out_str("OnPrevious reached begin, cannot go back more");
				return true;
			}
			
			// process current xfunction page
			//updateCurrentTheme();
			//invokeBasicGlobalEvent(GETNE_ON_UNDO); // undo current xfunction
			
			// process previous xfunction page
			if(!getPrevXF(strXFName))
			{
				out_str("Error. OnPrevious when no XF to go previous!");
				return true;
			}
			checkRemoveAfterCurXFs();
			
			m_bApplied = true;
			setControl(strXFName, true);
			
			///Joseph 07/03/07 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
			//this has been done in setcontrol
			//postGraphObjectMessageOnWizMode(true);		///Joseph 06/06/07 FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
			///End FIX_BUG_ON_POST_GRAPH_OBJ_MESSAGE_IN_WIZARD_MODE
			//invokeBasicGlobalEvent(GETNE_ON_UNDO); // undo previous xfunction
		}
		
		///---Sim 06-30-2007 GRAPH_CHANGE_MAY_CAUSE_GUI_CHANGE
		if ( ( GETNE_ON_CUSTOM_BUTTON1 <= nEventID && nEventID <= (GETNE_ON_CUSTOM_BUTTON1 + MAX_CUSTOM_BUTTON_NUM - 1) )
			||  GETNE_ON_GRAPH_OBJECT_CHANGE == nEventID )
		///---END GRAPH_CHANGE_MAY_CAUSE_GUI_CHANGE
		{
			// sim this code should be improve
			m_bXFDone = false;

			// string format is "D:1"
			vector<string> vs;
			strAux.GetTokens(vs, ':');
			if ( vs.GetSize() == 2 )
			{
				if ( 0 == vs[0].CompareNoCase("D") && 0 == vs[1].CompareNoCase("1") )
				{
					m_bXFDone = true;
				}
			}
		}
		
		///Joseph 04/23/07 SOME_EVENT_NEED_UPDATE_GUI
		//Could need, need to update GUI on apply.
		///---Sim 12-06-2007 IMPROVE_EVENT1_PARAM_STR_AUX
		//if(strAux.Compare(DLG_NEED_CHANGE_GRID) == 0)
		if ( is_aux_value(strAux, DLG_NEED_CHANGE_GRID) )
		///---END IMPROVE_EVENT1_PARAM_STR_AUX
			UpdateDynaControl(true, GETNEVENT_ON_CHANGE_UPDATE_GUI);
		///End SOME_EVENT_NEED_UPDATE_GUI
	}
	///---END IMPROVE_MULTI_THEME_FRAME_WORK
	
	
	return true;
}
//---------- end CUSTOM_APPLY_BUTTONS_CLEANUP

///---Sim 03-23-2007 IMPROVE_MULTI_THEME_FRAME_WORK	
/////Joseph 03/05/07 XF_WIZ_CLEANUP
//bool PageXFBar::unUoExecuteXF(TreeNode& trGetN)
//{
/////Joseph 03/11/07 XF_WIZ_CLEANUP	
///*
////---- CPY 3/11/07 PAGE_XF_BAR_FAILED_COMPILE
////	if(trGetN)
////		invokeBasicGlobalEvent(GETNE_ON_UNDO, trGetN);
	//invokeBasicGlobalEvent(GETNE_ON_UNDO);
////----
//*/
	//if(trGetN)
		//invokeBasicGlobalEvent(GETNE_ON_UNDO, trGetN);
/////End XF_WIZ_CLEANUP
	//return true;
//}
/////End XF_WIZ_CLEANUP
///---END IMPROVE_MULTI_THEME_FRAME_WORK	

///Joseph 04/12/07 FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1
bool PageXFBar::GetDlgSpecialButtonStatus(DWORD& dwEnables, int nEventID)
{
	///---Sim 05-11-2007 FIX_WIZARD_BUTTON_CONTROL
	//if(m_applyBtn.Enable)
	if ( 0 == (m_nFrameWorkState & XFBAR_FRAME_WORK_XF_NO_READY) )
	///---END FIX_WIZARD_BUTTON_CONTROL
		dwEnables |= GETNGEVT_OK_ENABLE;
	///Joseph 06/21/07 v8.0647 FIX_BUG_GET_BUTTON_DISABLE
	else
		dwEnables &= ~GETNGEVT_OK_ENABLE;
	///End FIX_BUG_GET_BUTTON_DISABLE
	return true;
}
///End FIX_BUG_GET_BUTTON_STATUS_ON_MORE_EVENT_IN_EVENT1


///Joseph 04/13/07 SHOULD_SUPPORT_MORE_CUSTOMBUTTON_EVENT
BOOL PageXFBar::OnClickCustomButton(int nID)
{
	if(nID >= IDC_GETN_CUSTOM_BTN1 && nID <= IDC_GETN_CUSTOM_BTN4)
	{
		int nn = nID - IDC_GETN_CUSTOM_BTN1 + 1;// CUSTOM_BUTTON = 1,2,3,4
		DWORD dw = CUSTOM_BUTTON_TO_GETNE_EVENT(nn);
		invokeBasicGlobalEvent(dw);
	}
	else
		out_int("Invalid button id for custom button: ", nID);
	return TRUE;
}
///End SHOULD_SUPPORT_MORE_CUSTOMBUTTON_EVENT
