// SelWfTemplateDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ViewWfTemplateDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CViewWfTemplateDlg dialog


CViewWfTemplateDlg::CViewWfTemplateDlg(CWnd* pParent /*=NULL*/)
	: CaplResizableDialog(CViewWfTemplateDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CViewWfTemplateDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_frame=0;

	m_wf_mgr=0;
	m_template=0;
	m_task_for_sel=0;
}


void CViewWfTemplateDlg::DoDataExchange(CDataExchange* pDX)
{
	CaplResizableDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CViewWfTemplateDlg)
	DDX_Control(pDX, IDCANCEL, m_cancel_btn);
	DDX_Control(pDX, IDC_GRAPH, m_graph_ramka);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CViewWfTemplateDlg, CaplResizableDialog)
	//{{AFX_MSG_MAP(CViewWfTemplateDlg)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CViewWfTemplateDlg message handlers

BOOL CViewWfTemplateDlg::OnInitDialog() 
{
	CaplResizableDialog::OnInitDialog();
	
	RECT rect;
	m_graph_ramka.GetWindowRect(&rect);
	ScreenToClient(&rect);
	m_frame->MoveWindow(&rect,FALSE);

	AddAnchor(m_frame->m_hWnd, TOP_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDCANCEL, BOTTOM_RIGHT);
	
	m_frame->m_view->ZoomAllObj();

	CString id,name,buf;

	if(m_wf_mgr!=0)
	{
		m_wf_mgr->m_api->m_data.GetAttr(m_template,m_wf_mgr->a_action_id,id);
		m_wf_mgr->m_api->m_data.GetAttr(m_template,m_wf_mgr->a_action_name,name);
		buf=id+_T(" : ")+name;
		SetWindowText(buf);
	}

	m_cancel_btn.SetIcon(GetAplStdIco16(APLSTDICO_CANCEL));
	m_cancel_btn.SetFlat(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

int CViewWfTemplateDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CaplResizableDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	
	RECT rect={0,0,10,10};
	m_frame=(CaplWfTemplateFrame*)(RUNTIME_CLASS(CaplWfTemplateFrame)->CreateObject());

	m_frame->m_wf_mgr=m_wf_mgr;
	m_frame->m_template=m_template;
	m_frame->m_task_for_sel=m_task_for_sel;

	m_frame->Create(0,_T("aaa"),WS_CHILD|WS_VISIBLE,	rect,this);

	
	return 0;
}
