/*
 *=======================================================================================
 * Name        :dlgconfl.h
 *
 * Author      :vincent lhullier             Date :21/07/97
 *
 * Description :implementation of dialog box to show section differences
 *=======================================================================================
 * Modification -> Author :                  Date :
 * Description :
 *=======================================================================================
 */

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#if !defined(AFX_DLGCONFL_H__6184144B_0199_11D1_8EF9_00609736731A__INCLUDED_)
#define AFX_DLGCONFL_H__6184144B_0199_11D1_8EF9_00609736731A__INCLUDED_
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "resource.h"
#include "MajData.h"
#include "SCR.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*
 =======================================================================================
 =======================================================================================
	PART of code to decompose a file/section into a tree of section
 =======================================================================================
 =======================================================================================
 */

/*
 =======================================================================================
	Constant
 =======================================================================================
 */
#define SCRT_C_cNew			0
#define SCRT_C_cDiff		1
#define SCRT_C_cSame		2
#define SCRT_C_cNewVss		3
#define SCRT_C_cNewLocal	4
#define SCRT_C_cComment		5

#define SCRT_C_cSection		0
#define SCRT_C_cEntry		1

/*
 =======================================================================================
	Structures 
 =======================================================================================
 */

typedef struct SCRT_tdstEntry_
{
	char			cType;
	char			*szName;
	unsigned short	uwNameLength;
	char			cCompState;
	long			lCompWith;
	HTREEITEM		hItem;
} SCRT_tdstEntry;


typedef struct SCRT_tdstSection_
{
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	/* same entry than SCR_tdstSection entry       */
	char							cType;
	char							*szName;
	unsigned short					uwNameLength;
	char							cCompState;
	long							lCompWith;
	HTREEITEM						hItem;
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	char							*szEndSection;
	BOOL							bNameIsAllocate;
	long							lNumberOfElements;
	SCRT_tdstEntry					**d_p_stElement;
	//long							lNumberOfEntries;
	//SCRT_tdstSectionEntry			*d_stEntry;
	//long							lNumberOfSubSections;
	//struct SCRT_tdstSectionTree_	*d_stSubSection;
} SCRT_tdstSection;

/*
 =======================================================================================
	Functions
 =======================================================================================
 */

void SCRT_fn_vClean( SCRT_tdstSection *_p_stSection );
void SCRT_fn_vFree ( SCRT_tdstSection *_p_stSection );
void SCRT_fn_vBuildSectionTree( SCRT_tdstSection *_p_stSection, SCR_tdst_File_Description *_p_stContent, char *_szName, unsigned short _uwNameLength, BOOL bFile );
void SCRT_fn_vInitAndBuildSectionTree( SCRT_tdstSection *_p_stSection, char *_szSectionContent, char *_szFileName );
BOOL SCRT_fn_bCompareSectionTree( SCRT_tdstSection *_p_stSection1, SCRT_tdstSection *_p_stSection2 );

/*
 =======================================================================================
 =======================================================================================
	CConflictDlg dialog
 =======================================================================================
 =======================================================================================
 */

#define C_cDisplayText	0
#define C_cDisplayTree	1

class CConflictDlg : public CDialog
{
  public:

	/*==> section name and user name (name of user that makes the update that generate the conflict )*/
	char					*m_szSectionName;
	char					*m_szUserName;

	/*==> variable to manage Vss section */
	char					*m_szVssSection;
  	CRichEditCtrl			m_oVssRichEdit;
	SCRT_tdstSection		m_stVssTree;
	CTreeCtrl				*m_p_oVssTree;

	/*==> variable to manage Local section */
	CRichEditCtrl			m_oLocalRichEdit;
	char					*m_szLocalSection;
	SCRT_tdstSection		m_stLocalTree;
	CTreeCtrl				*m_p_oLocalTree;

	/*==> variable to manage merged section (not yet used ) */
	SCRT_tdstSection		m_szMergeSection;
	CTreeCtrl				*m_p_oMergeTree;

	/*==> char format structure (for CRichEditCtrl display ) */
	CHARFORMAT				m_stCharFormat;

	/*==> Section display mode (tree or edit) */
	char					m_cDisplayMode;
	
	/*==> use to know if some message on tree or Rich Edit are generated by code */
	BOOL					m_bLocalOp;
	
	/*==> image list and array of icons for Tree Control */
	CImageList				m_oImageList;
	HICON					m_a_hIcon[7];

	/*==> Id of some dialog control for resizing operation */
	char m_cNbBottomButtons;
	UINT m_a_uiBottomButton[ 3 ];

  // Construction
  public:
	CConflictDlg(CWnd* pParent = NULL);   // standard constructor
	~CConflictDlg();

	/*==> to change display mode of section : tree or text */
	void m_fn_vChangeDisplayMode( char _cMode );

	/*==> access function to set section and user names and contents */
	void m_fn_vSetSectionName( char *_szSectionName ) { m_szSectionName = _szSectionName; }
	void m_fn_vSetUserName( char *_szUserName ) { m_szUserName = _szUserName; }
	void m_fn_vSetVssSection( char *_szVssSection ) { m_szVssSection = _szVssSection; }
	void m_fn_vSetLocalSection( char *_szLocalSection ) { m_szLocalSection = _szLocalSection; }

	/*==> fill a tree control with a section */
	void m_fn_vFillTree( CTreeCtrl *_p_oTree, SCRT_tdstSection *_p_stSection, HTREEITEM _hParent, int _iImage, BOOL _bVss );

	/*==> low level functions to add text in a RichEdit control */
	long m_fn_RE_lAddText( CRichEditCtrl *_p_oRE, char *_szText, char *_szEndText, char _cType );
	void m_fn_RE_vRecaleLine( CRichEditCtrl *_p_oRE1, CRichEditCtrl *_p_oRE2 );

	/*==> Low level functions to print section part in a Rich Edit control */
	char *m_fn_RE_vPrintSectionBeginning( CRichEditCtrl *_p_oRE, SCRT_tdstSection *_p_stSection, char *_szFrom, BOOL _bVss );
	char *m_fn_RE_vPrintEntry( CRichEditCtrl *_p_oRE, SCRT_tdstEntry *_p_stEntry, char *_szFrom, BOOL _bVss );
	char *m_fn_RE_vPrintSectionEnd( CRichEditCtrl *_p_oRE, SCRT_tdstSection *_p_stSection, char *_szFrom, BOOL _bVss );

	/*==> High level function to print an entire section or two parrallel section in one or two rich edit control */
	char *m_fn_RE_vPrintSection( CRichEditCtrl *_p_oRE, SCRT_tdstSection *_p_stSection, char *_szFrom, BOOL _bVss );
	void m_fn_RE_vPrintTwoSection(SCRT_tdstSection *_p_stVssSection,char **_p_szVssFrom, SCRT_tdstSection *_p_stLclSection,char **_p_szLclFrom );
	void m_fn_RE_vFill( void );

  // Dialog Data
	//{{AFX_DATA(CConflictDlg)
	enum { IDD = IDD_DIALOG_CONFLICT };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA

  // Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CConflictDlg)
	//}}AFX_VIRTUAL



  // Implementation
  protected:

	// Generated message map functions
	//{{AFX_MSG(CConflictDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnDestroy();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSizing( UINT nSide, LPRECT lpRect );
	afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
	afx_msg void OnSelchangedTreeLocal(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnItemexpandedTreeLocal(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSelchangedTreeVss(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnItemexpandedTreeVss(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnVscrollRicheditLocal();
	afx_msg void OnVscrollRicheditVss();
	afx_msg void OnButtonTreetext();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#endif // !defined(AFX_DLGCONFL_H__6184144B_0199_11D1_8EF9_00609736731A__INCLUDED_)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
