/*
	Folger 09/05/07 SHOW_ERROR_STATUS_BAR
*/

#ifndef _COL_PROPERTIES_H_
#define _COL_PROPERTIES_H_

#define STR_DLG_NAME 					_L("Column Properties")
/// Nicole 07/05/2007 v8.0655 REMOVE_SPACE_FOR_LOCATION_STRING
//#define STR_COL_PROPERTIES				_L("  Format  ")
#define STR_COL_PROPERTIES				" " + _L("Format") + " "
/// END REMOVE_SPACE_FOR_LOCATION_STRING
///Jasmine 08/13/07 MAKE_APPLY_UNDOABLE
#define BEFORE_UNDO_BLOCK				int idBefore = Project.UndoBlockId(); { UndoBlock block;
#define AFTER_UNDO_BLOCK				} int idAfter = Project.UndoBlockId(); 
///End MAKE_APPLY_UNDOABLE
enum{COL_PROPERTY_TAB, COL_ENUMERATE_TAB, COL_USER_INFO_TAB};	///Jasmine 11/29/06 ADD_TAB_FOR_MORE_CONTENT
/*
#define ERRMSG_RENAME_FAIL(_ColName)	_L("Column name ")+_ColName+_L(" has already been used by another column, Please choose another name.")
#define ERRMSG_ENUMERATE_NAME_FAIL 		_L("One of enumerate name has been used by another column.")
#define ERRMSG_ERROR_FORMULA			_L("Unmatched parethesis are found in column formula.")

#define PROMPT_MSG_APPLY_CHANGE			_L("Would you like to apply the change now?\nClick 'No' the change will lose.")

#define ROW_COL_NAME				0
#define ROW_COL_FORMAT				4
#define ROW_COL_NUMERIC_DISPLAY		6
#define ROW_COL_NUMERIC_INPUT		ROW_COL_NUMERIC_DISPLAY+1
#define ROW_COL_WIDTH				m_treeEditCntrl.GetRows()-2

#define	COLUMN_TYPE_SEL_TEXT_NUMERIC		6
#define COLUMN_INTERNAL_DATA_SEL_COMPLEX	4

enum {COL_TAB_PROPERTIES, COL_TAB_SET_VALUES};

enum {COL_NAME_SET_SUCCESS, COL_NAME_ALREADY_EXIST, COL_NAME_ENUMERATE_FAIL};
enum {COL_UPDATE_FINISHED, COL_READ_DETAIL };
*/
///Jasmine 03/21/07 MODIFICATION_EDIT_USER_TREE
///Jasmine 01/15/07 EDIT_USER_TREE
enum{
	EDIT_MODE_NONE,	//read-only
	EDIT_MODE_ADD, 	//editable, add, no delete
	EDIT_MODE_DELETE	//editable, add and delete
};
///End EDIT_USER_TREE
///End MODIFICATION_EDIT_USER_TREE
class ColDlg : public DynaDlg
{
public:
	ColDlg() : DynaDlg(IDD_COL_PROPERTY_DLG, NULL, "ODlg8")
	{
		m_bDeleteOnDestroy = true; //CPY 7/8/05 PROPER_MODLESS_DLG_HANDLING
	}
	~ColDlg()
	{
		if(m_pDataOB)
			delete m_pDataOB;
	}
	
	int Create(HWND hWndParent = NULL)
	{
		InitMsgMap();// will be called from internal later
		
		DWORD dwDlgOptions = 0;//DLG_TITLE_TO_HAVE_PAGE_NAME;
		int nRet = DynaDlg::Create(hWndParent, dwDlgOptions);
		//Visible=true;
		return nRet;
	}
protected :
	
EVENTS_BEGIN
	ON_INIT(OnInitDialog) 
	ON_DESTROY(OnDestroy)
	ON_READY(OnReady)
		
	ON_SYSCOMMAND(OnSystemCommand)//---- CPY 7/8/05 PROPER_MODLESS_DLG_HANDLING, make min button to rollup dialog

	ON_HELPINFO(OnHelp) /// CPY 2007-10-10 v8.0723 WKS_PROP_DLG_SEND_TAB_ID_TO_HELP
	
	ON_SIZE(OnDlgResize)
	ON_GETMINMAXINFO(OnMinMaxInfo) //---- CPY 5/14/06 BETTER_DIALOG_POS_SIZE
	///Jasmine 10/08/06 USE_SAME_NAME_AS_VIRTUAL_FUNC_IN_DYNA_DLG
	ON_CHANGE_LAYER( OnChangeLayer )//OnActiveLayerChange )
	ON_CHANGE_PAGE( OnChangePage )//OnActivePageChange )
	ON_CHANGE_SELECTION( OnSelectionChange )
	ON_CHANGE_DATASET(OnChangeDataset )//OnActiveDataChange)
	///End USE_SAME_NAME_AS_VIRTUAL_FUNC_IN_DYNA_DLG	
	ON_OK(OnClickOK)
	ON_CANCEL(OnClickCancel)
	ON_BN_CLICKED(IDC_APPLY_BTN, OnApply)
	ON_BN_CLICKED(IDC_PREVIOUS_BTN, OnClickPrevious)
	ON_BN_CLICKED(IDC_NEXT_BTN, OnClickNext)
	ON_TAB_SEL_CHANGE(IDC_COL_PROPERTY_TAB, OnTabChange) ///Jasmine 11/29/06 ADD_TAB_FOR_MORE_CONTENT
	ON_GETNDLG_MSGS(IDC_COL_FORMAT_GRID)
	ON_USER_MSG(WM_USER_TREEEDITOR_VALUE_CHANGE, OnAfterValueChange)
	ON_USER_MSG(WM_USER_RESET_GUI, OnResetTree) //--- CPY 2/24/06 DO_NOT_SET_TREE_INSIDE_ON_AFTER_VAL_CHANGE
	ON_CONTEXTMENU(OnShowMenu)
	///Joseph 01/31/07 QA70-9327 DDK_SAVING_OF_OCDDK_DIALOG_PLACEMENTS
	ON_INIT_SIZE(OnInitSize)
	ON_RESTORESIZE(OnRestoreSize)
	///End DDK_SAVING_OF_OCDDK_DIALOG_PLACEMENTS
EVENTS_END
	BOOL OnDestroy(void);//---- CPY 7/8/05 PROPER_MODLESS_DLG_HANDLING
	BOOL OnReady();
	
	BOOL OnHelp(int &nHelpID, int nIdCtrlFocus);	/// CPY 2007-10-10 v8.0723 WKS_PROP_DLG_SEND_TAB_ID_TO_HELP

	BOOL OnInitDialog();
	BOOL OnDlgResize(int nType, int cx, int cy);
	BOOL OnClickOK();
	BOOL OnClickCancel();
	BOOL OnApply(Control ctrl);
	BOOL OnClickPrevious(Control ctrl);
	BOOL OnClickNext(Control ctrl);
	BOOL OnTabChange(Control ctrl);	///Jasmine 11/29/06 ADD_TAB_FOR_MORE_CONTENT
	///Jasmine 10/08/06 USE_SAME_NAME_AS_VIRTUAL_FUNC_IN_DYNA_DLG
	BOOL OnChangeLayer();//OnActiveLayerChange();
	BOOL OnChangePage();//OnActivePageChange();
	BOOL OnSelectionChange();
	BOOL OnChangeDataset();//OnActiveDataChange();
	///End USE_SAME_NAME_AS_VIRTUAL_FUNC_IN_DYNA_DLG
	void OnAfterValueChange(int nRow, DWORD lParam);
	void OnResetTree(DWORD wParam, DWORD lParam);
	BOOL OnShowMenu(UINT nResIDCtrl, int nx, int ny);
	///Joseph 01/31/07 QA70-9327 DDK_SAVING_OF_OCDDK_DIALOG_PLACEMENTS
	BOOL OnInitSize(int &left, int &top, int &right, int  &bottom);
	BOOL OnRestoreSize(DWORD dwSizeInfo);
	bool GetDlgOptimalSize(SIZE& sz);
	bool SetInitSize();
	///End DDK_SAVING_OF_OCDDK_DIALOG_PLACEMENTS
protected :
	void GetActiveLayer();
	
	void ConstructTree();
	
private:
	bool createDataObject();
	void onTabChange();	///Jasmine 11/29/06 ADD_TAB_FOR_MORE_CONTENT
	void onAfterChange();
	bool isChanged();
	void onAfterApply();
	
	void updateDialogTitle();

	void update(LPCSTR lpcszDebugFrom = NULL, bool bInit = true, bool bCallHandlers = true);

	int getPageType();
	int getUserInfoLevel(const TreeNode tr, TreeNode& trRoot);
	//------ Folger 09/05/07 SHOW_ERROR_STATUS_BAR
	void resizeDialog(int cx = 0, int cy = 0);
	void checkShowStatusBar();
	bool setCheckErrorStatus(int nErr);
	//------ End SHOW_ERROR_STATUS_BAR
private :
	DataObjectManager*		m_pDataOB;
	bool					m_bDeleteOnDestroy; //CPY 7/8/05 PROPER_MODLESS_DLG_HANDLING
	TabControl 				m_tab;	///Jasmine 11/29/06 ADD_TAB_FOR_MORE_CONTENT
	vector<int>				m_vnSelRows;
	vector<int>				m_vnSelCols;
	
	Button					m_btnPrevious;
	Button					m_btnNext;
	
	Button					m_btnOK;
	Button					m_btnApply;
	
	DataObject				m_dataob;
	Layer					m_layActive;
	bool					m_bIsReady;	//true, allow select/set other columns
	//------ Folger 09/05/07 SHOW_ERROR_STATUS_BAR
	int			m_nErr;
	//Button		m_btnErrMessage;	///Jasmine 05/22/08 m_btnErrMessage_IS_IN_BASIC_CLASS_DYNA_DLG
	//------ End SHOW_ERROR_STATUS_BAR
};

#endif //_COL_PROPERTIES_H_