// aplWfTemplateFrame.cpp : implementation file
//

#include "stdafx.h"
#include "aplWfTemplateFrame.h"
#include "aplWfTemlateView.h"
#include "resource.h"

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


/////////////////////////////////////////////////////////////////////////////
// CaplWfTemplateFrame

IMPLEMENT_DYNCREATE(CaplWfTemplateFrame, CFrameWnd)

CaplWfTemplateFrame::CaplWfTemplateFrame()
{
	m_view=0;

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

CaplWfTemplateFrame::~CaplWfTemplateFrame()
{
}


BEGIN_MESSAGE_MAP(CaplWfTemplateFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CaplWfTemplateFrame)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CaplWfTemplateFrame message handlers

BOOL CaplWfTemplateFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class

	CCreateContext context;
	context.m_pNewViewClass = RUNTIME_CLASS(CaplWFTemplateView);

	m_view = (CaplWFTemplateView*)CreateView(&context, AFX_IDW_PANE_FIRST);
	if(m_view == NULL) return FALSE;
	
	SetActiveView(m_view, FALSE);
	
	if(m_wf_mgr!=0)
	{
		m_view->m_wf_mgr=m_wf_mgr;
		m_view->m_api=m_wf_mgr->m_api;
		m_view->m_prc=m_template;
		m_view->m_task_for_sel=m_task_for_sel;	
	}
	
	m_view->InitialUpdate();
	
	return CFrameWnd::OnCreateClient(lpcs, pContext);
}

int CaplWfTemplateFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this,TBSTYLE_FLAT, WS_CHILD|WS_VISIBLE| CBRS_TOOLTIPS|CBRS_TOP
		/*!| CBRS_NOALIGN| CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC*/,
		CRect(0,0,0,0), AFX_IDW_TOOLBAR) ||
		!m_wndToolBar.LoadToolBar(IDR_WF_TEMPL_VIEW_TB))
	{
		TRACE(_T("Failed to create toolbar\n"));
		return -1;      // fail to create
	}

	m_wndToolBar.EnableToolTips();
	
	CBitmap bm;
	bm.LoadBitmap(IDR_TC_WF_TEMPL_VIEW_TB);
	m_il.Create(20, 20, ILC_COLOR24|ILC_MASK, 0, 100);
	m_il.Add(&bm, RGB(192,192,192));
	bm.DeleteObject();

	m_wndToolBar.GetToolBarCtrl().SetImageList(&m_il);

	


/*
	if (!m_templates_frame.Create(_T("Информационная панель"), this, CSize(300, 50),
	        TRUE, 12345))
    {
		TRACE(_T("Failed to create mybar\n"));return -1;      // fail to create
	}

	m_templates_frame.SetBarStyle(m_templates_frame.GetBarStyle() |
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
// До ReBar	m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP);

	m_templates_frame.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_templates_frame, AFX_IDW_DOCKBAR_LEFT);
	DockControlBar(&m_wndToolBar);*/
	return 0;
}
