// EffectEditWin.cpp : implementation file
//

#include "stdafx.h"
#include "PixelWhipPro.h"
#include "EffectEditWin.h"
#include "TreeParamView.h"
#include "DataParamView.h"


/////////////////////////////////////////////////////////////////////////////
// CEffectEditWin

IMPLEMENT_DYNCREATE(CEffectEditWin, CFrameWnd)

CEffectEditWin::CEffectEditWin()
{
	ViewVar=false;
}

CEffectEditWin::~CEffectEditWin()
{
}


BEGIN_MESSAGE_MAP(CEffectEditWin, CFrameWnd)
	//{{AFX_MSG_MAP(CEffectEditWin)
	ON_WM_CLOSE()
	ON_COMMAND(ID_VIEW_VIEWVARIANCEVALUES, OnViewViewvariancevalues)
	ON_UPDATE_COMMAND_UI(ID_VIEW_VIEWVARIANCEVALUES, OnUpdateViewViewvariancevalues)
	ON_WM_CREATE()
	ON_COMMAND(ID_VIEW_VIEWVARIANCECURVE, OnViewViewvariancecurve)
	ON_UPDATE_COMMAND_UI(ID_VIEW_VIEWVARIANCECURVE, OnUpdateViewViewvariancecurve)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEffectEditWin message handlers

void CEffectEditWin::OnClose() 
{
		ShowWindow(SW_HIDE);

//	CFrameWnd::OnClose();
}


void CEffectEditWin::Create(CWnd *Parent)
{
CRect rct=rectDefault;
rct.right=rct.left+512;
rct.bottom=rct.top+640;
//CWnd::Create(NULL,"Effect Parameters",WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,rct,Parent,IDR_PARAMMENU);
//CFrameWnd::Create(NULL,"Effect Parameters",WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,rct,Parent,MAKEINTRESOURCE(IDR_PARAMMENU));
//LoadFrame(IDR_PARAMMENU,WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,Parent,NULL);
LoadFrame(IDR_PARAMMENU,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);
}


void CEffectEditWin::Refresh()
{
TreePane->Refresh();
//DataPane->Refresh();
}


void CEffectEditWin::OnViewViewvariancevalues() 
{
	ViewVar=!ViewVar;
	DataPane->Refresh();
}

void CEffectEditWin::OnUpdateViewViewvariancevalues(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(ViewVar?1:0);

}

int CEffectEditWin::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_PARAMMENU))
	{
		TRACE0("Failed to create toolbar\n");
	}


	// TODO: Delete these three lines if you don't want the toolbar to be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

m_splitter.CreateStatic(this,1,2);
m_splitter.CreateView(0,0,RUNTIME_CLASS(CTreeParamView),CSize(200,1024),NULL);
m_splitter.CreateView(0,1,RUNTIME_CLASS(CDataParamView),CSize(200,1024),NULL);

TreePane=(CTreeParamView *)m_splitter.GetPane(0,0);
DataPane=(CDataParamView *)m_splitter.GetPane(0,1);

RecalcLayout();

	
	return 0;
}

BOOL CEffectEditWin::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class
//	cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
//	cs.lpszClass = AfxRegisterWndClass(0);
	return CFrameWnd::PreCreateWindow(cs);
}

BOOL CEffectEditWin::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

void CEffectEditWin::OnViewViewvariancecurve() 
{
	// TODO: Add your command handler code here
	ViewVar=!ViewVar;
	
}

void CEffectEditWin::OnUpdateViewViewvariancecurve(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(ViewVar?1:0);
	
}
