// MainFrm.cpp : implementation of the CMainFrame class
////////////////////////////////////////////////////////
#include "StdAfx.h"

#include "_AInterf.hpp"
#include "EDACFmMn.hpp"
#include "EDACVwAc.hpp"
#include "EDACVwMS.hpp"
#include "EDACCnst.hpp"

//-----------------IR-------------------------
#include "EdIRDVVw.hpp"
#include "EDACQuer.hpp"
//--------------------------------------------


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

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CSplitFrame)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_HELPINFO()
//	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

//*******************************************************************************
CMainFrame::CMainFrame()
{

}

//*******************************************************************************
CMainFrame::~CMainFrame()
{
	//Closes Help if necessary
	::WinHelp(	m_hWnd,
							LPCTSTR(g_pclInterface->m_clDocument.m_csHelpFileNameAndPath),
							HELP_QUIT,
							0);
}

//*******************************************************************************
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	if (!(CreateSplitter(C_cVerticalSplitter, C_NUMBER_OF_PANES)))
		return FALSE;

	HINSTANCE hOldInstance = AfxGetResourceHandle();

	//Creates Dialog List View
	CPA_DialogList *pclDialogList = new CPA_DialogList;
	g_pclInterface->m_clDocument.m_pclDialogList = pclDialogList;
	pclDialogList->fn_vInitDialog(g_pclInterface, this);
	SetPaneView(C_ROW_INDEX_LISTS,
							pclDialogList,
							"Selection",
							g_pclInterface->m_clDocument.m_ulListViewHeight);

	AfxSetResourceHandle( g_stActorEditorIdentity.hModule );

	//Creates other views
	if ( !CreateView(	C_ROW_INDEX_MINI_STRUC,
										RUNTIME_CLASS(EdActors_MiniStrucView),
										"Mini Structures",
										g_pclInterface->m_clDocument.m_ulMSViewHeight) )
		return FALSE;

	if ( !CreateView(	C_ROW_INDEX_CONTROL,
										RUNTIME_CLASS(EdActors_ActorsView),
										"Editor's Control",
										g_pclInterface->m_clDocument.m_ulControlViewHeight) )
		return FALSE;

//-----------------IR-------------------------
	if ( !CreateView(	C_ROW_INDEX_DES_VAR,
										EDAC_fn_pclDesignerVariableView_GetRuntimeClass(),
										"Designer Variables",
										C_wCaptionHeight) )
		return FALSE;
//--------------------------------------------
	
		//Manually calls OnInitialUpdate for all views !!!!!
		EdActors_MiniStrucView *pclMSView = (EdActors_MiniStrucView *)m_fn_p_oGetPane(C_ROW_INDEX_MINI_STRUC);
		pclMSView->OnInitialUpdate();
		
		EdActors_ActorsView *pclActorsView = (EdActors_ActorsView *)m_fn_p_oGetPane(C_ROW_INDEX_CONTROL);
		pclActorsView->OnInitialUpdate();
		
//-----------------IR-------------------------
		CPA_EdIR_DesignerVariablesView *pclDesVarView = (CPA_EdIR_DesignerVariablesView *)m_fn_p_oGetPane(C_ROW_INDEX_DES_VAR);
		pclDesVarView->OnInitialUpdate();
		//SetPaneSize(C_ROW_INDEX_DES_VAR,C_wCaptionHeight);

		short wScreenHeight;

		HDC	  hdc = ::GetWindowDC(NULL);
		wScreenHeight = (short)GetDeviceCaps(hdc, VERTRES);
		::ReleaseDC(NULL, hdc);

		EDAC_fn_vDesignerVariableView_SetOldHeight(pclDesVarView,wScreenHeight/C_NUMBER_OF_PANES);
//--------------------------------------------

	AfxSetResourceHandle( hOldInstance );

	return TRUE;
}

//*******************************************************************************
BOOL CMainFrame::OnHelpInfo(HELPINFO* pHelpInfo) 
{
	::WinHelp(m_hWnd,
						LPCTSTR(g_pclInterface->m_clDocument.m_csHelpFileNameAndPath),
						HELP_FINDER,
						0);
	
	return FALSE;
	//return FRMBase::OnHelpInfo(pHelpInfo);
}

//*******************************************************************************
void CMainFrame::OnPaint() 
{
//	static s_bFirstPass = TRUE;
	CPaintDC dc(this); // device context for painting
	
/*	if ( s_bFirstPass )
	{
		EdActors_ActorsView *pclActorsView = (EdActors_ActorsView *)m_fn_p_oGetPane(C_ROW_INDEX_CONTROL);
		pclActorsView->OnInitialUpdate();
		
		EdActors_MiniStrucView *pclMSView = (EdActors_MiniStrucView *)m_fn_p_oGetPane(C_ROW_INDEX_MINI_STRUC);
		pclMSView->OnInitialUpdate();
		
 		EdActors_NamesView *pclNamesView = (EdActors_NamesView *)m_fn_p_oGetPane(C_ROW_INDEX_INFO);
		pclNamesView->OnInitialUpdate();
		
//-----------------IR-------------------------
		CPA_EdIR_DesignerVariablesView *pclDesVarView = (CPA_EdIR_DesignerVariablesView *)m_fn_p_oGetPane(C_ROW_INDEX_DES_VAR);
		pclDesVarView->OnInitialUpdate();
//--------------------------------------------

		s_bFirstPass = FALSE;
	}*/
	
	// Do not call CSplitFrame::OnPaint() for painting messages
}


//*******************************************************************************
//*******************************************************************************
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	FRMBase::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	FRMBase::Dump(dc);
}

#endif //_DEBUG


