/*
 *******************************************************************************
 * MajDataDlg.h : header file
 *******************************************************************************
 */

#include "resource.h"
#include "DlgFile.h"
#include "ProgBar.h"

/*
 *******************************************************************************
 * CONSTANTS
 *******************************************************************************
 */
/* 
 * for cheat code flag
 */
#define C_lCheatPause	0x0001
#define C_lCheatUpdate	0x0002

/*
 * for line in RichEdit result window
 */
#define C_Result_cInfoLine	0
#define C_Result_cOkLine	1
#define C_Result_cErrorLine 2

/*
 * timer event ID
 */
#define C_uiBaseStatusTimer	1

/*
 *******************************************************************************
 * CMngDataDlg class
 *******************************************************************************
 */
class CMngDataDlg : public CDialog
{
  public:
	CMngDataDlg(CWnd* pParent = NULL);	// standard constructor

  // Dialog Data
	//{{AFX_DATA(CMngDataDlg)
	enum { IDD = IDD_MNGDATA_DIALOG };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMngDataDlg)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

  private:
	/* ==> cheat code */
	char			m_szCheat[6];
	long			m_lCheatFlag;
	
	/* ==> char buffer for different message */
	char			m_szMessage[1024];

	/* ==> result window */
	CRichEditCtrl	m_oRichEdit;
	CHARFORMAT		m_stCharFormat;
	
	/* ==> progress bar */
	CMyProgressBar	m_oProgress;

	/* ==> working status */
	BOOL			m_bWorkInProgress;
	BOOL			m_bRequestToStop;
	BOOL			m_bBatchObtain;

	/* window controls for resizing */
	UINT			m_a_uiEditControl[10];
	int				m_a_iSizeLeft[10];
	char			m_cNbEditBox;

	UINT			m_a_uiRightAlignedButton[6];
	char			m_cNbRightButtons;

	UINT			m_a_uiBottomButton[5];
	char			m_cNbBottomButtons;
	int				m_iHeightLeft;
	
	/* ==> dialog to display vss tree */
	CDialogFileList m_oFileDlg;

	/* ==> main dialog status */
	BOOL			m_bInitOK;
	BOOL			m_bQuitFromSysCommand;

	/* ==> timer for base status */
	BOOL			m_bBaseStatusTimerOn;
	UINT			m_uiBaseStatusTimer;

	/* ==> data for update */
	BOOL			m_bLocalExist;
	char			m_cVssStatus;


  private:
	void m_fn_vEnableButton( BOOL bEnable );
	void m_fn_vDisplayProgramData( void );
	void m_fn_vPause( void );
	void m_fn_vWriteResultToLogFile( char *szString );
	void m_fn_vFatalError( char *_szMessage );

	void m_fn_Result_vAddLine( char *szLine, char cLineType );
	void m_fn_Result_vResetContent();

	void m_fn_vInitProgessBar( int _iStart, int _iEnd );

	void m_fn_vDisplayBaseStatus( void );
	void m_fn_vSetTimerForBaseStatus( void );
	void m_fn_vKillTimerForBaseStatus( void );

	char m_fn_cDoModifFileDelete( tdstModif *_p_stModif );
	char m_fn_cDoModifFileModif( tdstModif *_p_stModif, BOOL _bForFile );
	char m_fn_cDoModifFileAdd( tdstModif *_p_stModif  );
	BOOL m_fn_bUpdate( void );
	BOOL m_fn_bOnCommandUpdate();

	BOOL m_fn_bUpdateWithConfig( long _lNumberOfFiles, char **d_szFile );
	BOOL m_fn_bOnCommandUpdateWithConfig( void );

	void m_fn_vGetObtainingTimeString( char *szString );
	void m_fn_vOnCommandObtain();

  // Implementation
  protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CMngDataDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnDestroy();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnCheckObtainMenu();
	afx_msg void OnButtonViewmodif();
	afx_msg void OnButtonBrowse();
	afx_msg void OnButtonRefresh();
	afx_msg void OnButtonLookobtain();
	afx_msg void OnButtonLookupdate();
	afx_msg void OnButtonVssfiles();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSizing( UINT nSide, LPRECT lpRect );
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnCheckHelp();
	afx_msg void OnButtonClearmodif();
	afx_msg void OnCheckUpdate();
	afx_msg void OnButtonStop();
	afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
	virtual void OnCancel();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnButtonChangemodif();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
