#if !defined(AFX_DLGMAIN_H__C3B78329_60A7_11D1_A944_00A0245D4B6C__INCLUDED_)
#define AFX_DLGMAIN_H__C3B78329_60A7_11D1_A944_00A0245D4B6C__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/*
 =======================================================================================
   Name:		DlgMain.h : header file

   Author:		Mihaela Tancu
   Description: File containing functions for main window
 =======================================================================================
 */
#include "GIItem.h"
#include <afxtempl.h>
#include "GIType.h"
#include "shlobj.h"

/*
 =======================================================================================
 * for writing a normal line or an error line in RichEdit result window
 =======================================================================================
 */
#define C_ComRes_cOkLine	0  
#define C_ComRes_cErrorLine 1


/////////////////////////////////////////////////////////////////////////////
// CDlgMain dialog

class CDlgMain : public CDialog
{
public:
	CTabCtrl	m_oPanel;				//used for the tab controls

	CListBox	*m_oListType;			//first list box with types
	CListBox	*m_oListObject;			//second list box with objects

	GI_Type		*m_p_oTypeAnims;		//the possible types in the first list box
	GI_Type		*m_p_oTypeTextures;		//in this way is easy to know at one time with what type we are working
	GI_Type		*m_p_oTypeLevels;

	int			m_iCountOfSelections;	//the number of all selections in all list associated with the types
	CProgressCtrl	m_oProgress;
	BOOL		m_bConversion;

	BOOL		m_bFirstShow;			//used for displaying a cross in front of an active object in the second list
	CDC			m_oCrossDC;
	CBitmap		m_oCrossBitmap;

	/* 
	 =======================================================================================
	 * window controls for resizing 
	 =======================================================================================
     */
	UINT			m_a_uiEditControls[6];  //used for the edit controls
	int				m_a_iSizeLeft[6];
	char			m_cNbEditBox;

	UINT			m_a_uiRightButtons[15];  //used for the right push buttons
	char			m_cNbRightButtons;

	UINT			m_a_uiRightBut[15];  //used for the right push buttons
	char			m_cNbRightBut;

	UINT			m_a_uiRadioButtons[15];  //used for the radio buttons
	char			m_cNbRadioButtons;

	UINT			m_a_uiGroupButtons[5];	//used for the group buttons
	char			m_cNbGroupButtons;

	/* 
	 =======================================================================================
	 * result windows: Result and Command
	 =======================================================================================
	 */
	CRichEditCtrl	m_oRichEditRes;			//used for the rich edit control Result
	CHARFORMAT		m_stCharFormatRes;
	
	CRichEditCtrl	m_oRichEditCom;			//used for the rich edit control Command
	CHARFORMAT		m_stCharFormatCom;

	BOOL			m_bInit;				// used for initialize

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

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


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDlgMain)
	protected:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	protected:
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

private:
	// when is selected the first panel show only its controls
	void m_fn_TabC_vShowControlsPanelDir() ;
	// when is selected the second panel show only its controls
	void m_fn_TabC_vShowControlsPanelSel() ;
	// when is selected the third panel show only its controls
	void m_fn_TabC_vShowControlsPanelRes() ;
	// set/reset the flag for convering or not the animations
	void mfn_vConvAnim();
	// set/reset the flag for convering or not the textures
	void mfn_vConvTextures();
	void mfn_vConvLevels();
	// free the allocated memory
	void mfn_vFreeMemory() ;
	void mfn_vFreeMemoryForType(GI_Type **_p_oType) ;
	// show the controls from the first panel
	// according to the parameter bChange
	void m_fn_TabC_vChangeShowControlsPanelDir(BOOL bChange) ;
	// Show or hide the buttons from the second panel 
	// according to the parameter bChange
	void m_fn_TabC_vChangeShowControlsPanelSel(BOOL bChange) ;
	// Show or hide the buttons from the third panel 
	// according to the parameter bChange
	void m_fn_TabC_vChangeShowControlsPanelRes(BOOL bChange) ;

	// write a line in the rich edit control 
	// with different color (red or black) for Ok or for Error
	void m_fn_ComRes_vWriteLine( char *szLine, char cLineType ,CRichEditCtrl *_oRichEdit, 
									CHARFORMAT *_stCharFormat);
	// delete the content of the rich edit control 
	void m_fn_ComRes_vDeleteLines( CRichEditCtrl *_oRichEdit);
	
	//test if exist the name of the executable file, the directories...
	BOOL m_fn_bWarningUser();
	//if the directories does not exist, inform the user 
	void m_fn_vShowPartialWarning(BOOL bSet, char *szPath, char *_szMessage, BOOL * bDisplay, int iID, char *szDir);
	//only call the function m_fn_bWarningUser() (till now) 
	BOOL m_fn_vTestIniDatas();
	//function used for start browsing from a directory specified (it applies for Textures and Default sub-directories of RawData directory)
	void m_fn_vBrowseStartingFromDirectory(char *szPath, int *iResult) ;
	//used for testing if in one directory exist some subdirectories (also the case for the RawData directory from which to select the sub-directories Textures and Default).
	BOOL m_fn_bExistDirectories(char *szPath);
	//obtained the structure needed for browsing	
	void m_fn_vBrowseDirectory(char* szPath, int *p_iResult, ITEMIDLIST *p_stItemRoot);
	//returning a flag which tells if in the specified path exist files
	BOOL m_fn_bGetFiles(char *szFile, HANDLE *hHandle, WIN32_FIND_DATA *stFindFileData);
	//complete the list with objects associated with a type from the informations stored inthe directory
	void m_fn_vGetDatas(char *szPath);
	//setting all the variables to the directories, and obtained all the datas in the list box with objects
	void m_fn_vGetAllTypes();
	//calling the function m_fn_vGetDatas for all types
	void m_fn_vGetSetDatasInList(char *szAnims, char *szTextures, char *szLevels);
	//if the directory exist, add the corresponding type in the list box
	void m_fn_vAddType(GI_Type * p_oType, char *szReturn, char *szType, char *szDir, int *iNumber);
	//add objects to the list with objects
	void m_fn_vCreateLists( CList<GI_Item *,GI_Item *> *_oListObject, char *szPath, char *szType, GI_Item * _p_oItem);
	//for the selected type create the list with objects associated with it (upadate the second list box with objects)
	void m_fn_vUpdateListBox(CList<GI_Item *,GI_Item *> *_oListObject,
									 char *szPath, char *szType);
	//select the first type in the first list box with types and update the info's 	for the objects
	void m_fn_vUpdateAll();
	//make all the objects actives/inactives in the list, modify corresponding the global and local number of selections 
	void m_fn_vSelectAllInList(GI_Type * _p_oType, BOOL bSet) ;
	//makes all the objects actives/inactives
	void m_fn_vSelectAll(BOOL bSet) ;
	//select a type, and for it call the function m_fn_vSelectAllInList
	void m_fn_vSelectAllForType(BOOL bSet) ;
	//it is not used anymore
	int  m_fn_iGetAllSelectionsInList(GI_Type * _p_oType) ;
	//return the total number of objects in all lists
	int  m_fn_iGetAllObjects();
	//modify the active/inactive state of the object(s)
	BOOL m_fn_bOnChangeActivation(GI_Item *_p_oItem, int iIndexItem );
	//depending on the flag bSet, modify the state of the object, and increment the total/local number of selections
	void m_fn_vChange(GI_Item *p_oItem, GI_Type *p_oType, BOOL bSet );
	//enable/disable the selections buttons in the second panel 
	void m_fn_vEnableButtons(BOOL bSet) ;
	//enable/disable the selections buttons in the second panel 
	void m_fn_TabC_vDisableAllButtons() ;
	void m_fn_TabC_vEnableButtons() ;
	//enable/disable the buttons Convert and ClearAll
	void m_fn_vEnableButtonConvert();
	//enable/disable the button All
	void m_fn_vEnableButtonAll() ;
	//change the color of a type depending if it has no objects selected, some objects selected, all objects selected
	void m_fn_vOnDrawItemListBoxType(LPDRAWITEMSTRUCT lpDIS);
	//draw a cross in front of an active object
	void m_fn_vOnDrawItemListBoxObject(LPDRAWITEMSTRUCT lpDIS);
	//add a type in the list box with types, only if in the corresponding directory are the corresponding datas
	int m_fn_iAddTestDirType(char *szFiles);
	//set the global variable of the type to the new type if the number of the elements for that type is not zero
	void m_fn_vSetTypeInList(GI_Type ** _p_oType, char *szType, int iNumber);

	void m_fn_iGetAllFamilies(GI_Item * p_oItem);
	void m_fn_iGetAllAnimations(GI_Item * p_oItem);
	void m_fn_iGetAllTextures(GI_Item * p_oItem);
	int m_fn_iInitBinGame(char *sString, GI_Item *p_oItem);
	char m_fn_cExecuteGame(char *szProgramName, char *szDirName, char *szLevelName, char *szDebug, char *szVersion, char *szFirst);
	void m_fn_vInitBinTextures( char *sString );

//	void m_fn_vBrowseStartingFromDirectory(char* szPath, int *p_iResult);
//	void m_fn_vBrowseDirectory(char* szPath, int *p_iResult, ITEMIDLIST *p_stItemRoot);

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CDlgMain)
	afx_msg BOOL OnInitDialog();
	afx_msg void OnDestroy();
	afx_msg void OnPaint();
	afx_msg void OnConvAnim();
	afx_msg void OnConvTextures();
	afx_msg void OnConvLevels();
	afx_msg void OnGenerateAuto();
	afx_msg void OnUsed();
	afx_msg void OnAll();
	afx_msg void OnTbl();
	afx_msg void OnButtonFix();
	afx_msg void OnBMP();
	afx_msg void OnTGA();
	afx_msg void OnConvert16();
	afx_msg void OnConvert32();
	afx_msg void OnSizing( UINT nSide, LPRECT lpRect );
	afx_msg void OnSelchangePanel(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnHelp();
	afx_msg void OnQuit();
	afx_msg void OnSelectAll();
	afx_msg void OnCheckZoo();
	afx_msg void OnSelectAllInList();
	afx_msg void OnClear();
	afx_msg void OnClearAll();
	afx_msg void OnButtonDebug();
	afx_msg void OnButtonBin();
	afx_msg void OnButtonRelease();
	afx_msg void OnButtonBrowseDestBinD();
	afx_msg void OnButtonBrowseSource();
	afx_msg void OnButtonBrowseDestBinR();
	afx_msg void OnBinarise();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSelchangeListType();
	afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDIS);
	afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) ;
	afx_msg void OnSelchangeListObject();
	afx_msg BOOL OnLButtonDownListBoxObject(MSG *pMsg);
	afx_msg BOOL OnKeyDownListBoxObject(MSG *pMsg);
	afx_msg void OnButtonBrowseExeFile();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DLGMAIN_H__C3B78329_60A7_11D1_A944_00A0245D4B6C__INCLUDED_)
