// CPAAbout.cpp : implementation file
//

#include "stdafx.h"

#ifdef ACTIVE_EDITOR

#include "ACP_Base.h"

#include "itf/CPAAbout.hpp"
#include "itf/CPAMWorl.hpp"
#include "itf/CPAEditB.hpp"
#include "itf/CPAProj.hpp"
#include "itf/CPAConst.hpp"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define M_List()        ((CListCtrl*)GetDlgItem(IDC_LIST_EDITOR))

/////////////////////////////////////////////////////////////////////////////
// CPA_DlgAbout dialog


CPA_DlgAbout::CPA_DlgAbout(CWnd* pParent /*=NULL*/)
	: CDialog(CPA_DlgAbout::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPA_DlgAbout)
	//}}AFX_DATA_INIT
}


void CPA_DlgAbout::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPA_DlgAbout)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPA_DlgAbout, CDialog)
	//{{AFX_MSG_MAP(CPA_DlgAbout)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPA_DlgAbout message handlers

BOOL CPA_DlgAbout::OnInitDialog()
{
	CDialog::OnInitDialog();

    // update application name
    GetDlgItem( IDC_ST_APPNAME ) -> SetWindowText( M_GetMainApp() -> m_csApplicationName );
    // update application version
    GetDlgItem( IDC_ST_APPVERSION ) -> SetWindowText( M_GetMainApp() -> m_csApplicationVersion );

    // update interface name
    GetDlgItem(IDC_ST_APPNAME2)->SetWindowText("Editors Interface");
    // update application version
    GetDlgItem(IDC_ST_APPVERSION2)->SetWindowText(C_szCPAVersion);

    // update editor list
    fn_vFillEditorList();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPA_DlgAbout::fn_vFillEditorList()
{
    CListCtrl *pLC = M_List();

    int iTaille = pLC -> GetStringWidth( "m" );
    // add column
    pLC -> InsertColumn(0,"Editor",LVCFMT_LEFT,iTaille*20);
    pLC -> InsertColumn(1,"Version",LVCFMT_LEFT,iTaille*20);
    pLC -> InsertColumn(2,"Author",LVCFMT_LEFT,iTaille*20);
    pLC -> DeleteAllItems();
    // add info
    CPA_List<CPA_EditorBase> *p_oList = m_p_oMainWorld -> GetListOfEditorBase();

    POSITION stPos = p_oList -> GetHeadPosition();
    WORD wR = 0;
    while ( stPos )
    {
        tdstEDTInfo *p_stInfo = p_oList -> GetNext( stPos ) -> GetEditorInfo();

        pLC -> InsertItem (wR, p_stInfo -> csName, 0);
        pLC -> SetItemText(wR, 1, p_stInfo -> csVersion);
        pLC -> SetItemText(wR, 2, p_stInfo -> csAuthor);
    }
}

#endif