//===========================================================================
// A3dKeyboardConfDlg.cpp : implementation of Keyboard Configuration Dialog
//
// Version			1.0
// Creation date	21/10/96
// Author:			Philippe Touillaud
//
// Revision date
// Author:			
//	(TEST SHARE)
// (c) Ubi Pictures 1996
//
//===========================================================================

#include "stdafx.h"

#ifdef ACTIVE_EDITOR
#include "acp_base.h"

#include "geo.h"
#include "gli.h"
#include "col.h"
#define HieFriend
#include "lst.hpp"
#include "spo.h"
#undef HieFriend

#include "itf/A3dKeybo.hpp"
#include "itf/CPAkacnf.hpp"
#include "itf/A3dkeyal.hpp"
#include "itf/CPAProj.Hpp"
#include "itf/CPARes.h"

/////////////////////////////////////////////////////////////////////////////
// A3d_KeyboardConfDlg dialog

// Constructor
A3d_KeyboardAllConfDlg::A3d_KeyboardAllConfDlg(void) : CDialog(A3d_KeyboardAllConfDlg::IDD, M_GetMainWnd())
{
	//{{AFX_DATA_INIT(A3d_KeyboardConfDlg)
	//}}AFX_DATA_INIT
}


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


BEGIN_MESSAGE_MAP(A3d_KeyboardAllConfDlg, CDialog)
	//{{AFX_MSG_MAP(A3d_KeyboardConfDlg)
    ON_COMMAND(IDOK, OnEdit)
    ON_LBN_DBLCLK(IDC_LIST1, OnEdit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


// Overrides
BOOL A3d_KeyboardAllConfDlg::OnInitDialog() 
{
	BOOL        bTemoin;
    POSITION    pos;
    CPA_KeyActionConfiguration *p_Current;

    pos = M_GetMainApp()->m_lstKeyboard.GetHeadPosition();
    while(pos)
    {
        p_Current = M_GetMainApp()->m_lstKeyboard.GetNext(pos);
        if(p_Current)
        {
			if (p_Current->IsInitFileValid())
				((CListBox *) GetDlgItem(IDC_LIST1))->AddString(p_Current->mfn_szGetObjectName());
        }
    }

	bTemoin = CDialog::OnInitDialog();
    if(bTemoin)
    {
	    UpdateData(FALSE);
    }

	return bTemoin;
}

BOOL A3d_KeyboardAllConfDlg::UpdateData(BOOL bSaveToClass)
{
	BOOL bReturn;
	if (bSaveToClass)
	{
		bReturn = CDialog::UpdateData(TRUE);
	}
	else
	{
		bReturn = CDialog::UpdateData(FALSE);
	}

	return bReturn;
}

void A3d_KeyboardAllConfDlg::OnEdit(void)
{
    int         iSel = ((CListBox *) GetDlgItem(IDC_LIST1))->GetCurSel();
    POSITION    pos;
    CPA_KeyActionConfiguration *p_Current;

    pos = M_GetMainApp()->m_lstKeyboard.GetHeadPosition();
    p_Current = M_GetMainApp()->m_lstKeyboard.GetHead();
    while(pos && iSel)
    {
        M_GetMainApp()->m_lstKeyboard.GetNext(pos);
        p_Current = M_GetMainApp()->m_lstKeyboard.GetAt(pos);
		if (p_Current->IsInitFileValid())
			iSel--;
    }

    p_Current->mfn_vDialog(this, p_Current->mfn_szGetObjectName());
}

#endif // ACTIVE_EDITOR