// GroupProps.cpp : implementation file
//

#include "stdafx.h"
#include "MW4GameEd2.h"
#include "GroupProps.h"
#include "GUIObjectList.h"
#include "ObjPanelDlg.h"


/////////////////////////////////////////////////////////////////////////////
// CGroupProps dialog


CGroupProps::CGroupProps(GUIObjectList *gobj,UndoCommand **cmd,CWnd* pParent /*=NULL*/)
	: CPanelDlg(CGroupProps::IDD, pParent)
{
	MyList=gobj;
	CmdLst=cmd;
	//{{AFX_DATA_INIT(CGroupProps)
	//}}AFX_DATA_INIT
}


void CGroupProps::DoDataExchange(CDataExchange* pDX)
{
	CPanelDlg::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGroupProps)
	DDX_Control(pDX, IDC_MEMBERLIST, m_MemList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGroupProps, CPanelDlg)
	//{{AFX_MSG_MAP(CGroupProps)
	ON_LBN_DBLCLK(IDC_MEMBERLIST, OnDblclkMemberlist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGroupProps message handlers

BOOL CGroupProps::OnInitDialog() 
{
	CPanelDlg::OnInitDialog();
	UpdateData(FALSE);
	
	int itm;

	for(int i=0;i<MyList->GetObjectCount();i++)
	{
	itm=m_MemList.AddString(MyList->GetObject(i)->GetName());
	m_MemList.SetItemDataPtr(itm,MyList->GetObject(i));
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CGroupProps::OnOK() 
{
	UpdateData(TRUE);
	CPanelDlg::OnOK();
}

void CGroupProps::OnDblclkMemberlist() 
{
	// TODO: Add your control notification handler code here
	int itm=m_MemList.GetCurSel();
	EdGUIObject *gobj;
	gobj=(EdGUIObject *)m_MemList.GetItemDataPtr(itm);

	CObjPanelDlg pan_dlg;
	gobj->AddPanel(&pan_dlg,CmdLst);
	pan_dlg.DoModal();

}
