#include "StdAfx.h"
#define APL_PSSAPP_NOAUTOLIB
#include "CommonClasses.h"

//CaplAddinViews::CaplAddinViews()
//{
//	m_Data.RemoveAll();
//}
//
//CaplAddinViews::~CaplAddinViews()
//{
//	DeleteAllViews();
//}
//void CaplAddinViews::AddView(CView*view, DWORD type, int pos, CString name, CString descr, bool show, long viewtype, long viewid)
//{
//	CaplViewInfo* vi = new CaplViewInfo;
//	vi->pos = pos;
//	vi->tab_name = name;
//	vi->tab_descr = descr;
//	vi->type = type;
//	vi->view = view;
//	vi->show =	 show;
//	vi->viewtype= viewtype;
//	vi->viewid= viewid;
//	m_Data.Add(vi);
//}
//	
//void CaplAddinViews::DeleteAllViews()
//{
//	while(m_Data.GetSize()>0)
//	{
//		CaplViewInfo *vi = m_Data.GetAt(0);
//		if(vi!=0)
//		{
//			delete vi;
//		}
//		m_Data.RemoveAt(0);
//	}
//}
//
//int CaplAddinViews::GetSize() 
//{
//	return m_Data.GetSize();
//}
//
//int CaplAddinViews::GetPos(int ind)
//{
//	if(ind<0 || ind>=GetSize()) return -1;
//	CaplViewInfo* vi = m_Data.GetAt(ind);
//	return vi->pos;
//}
//
//CaplViewInfo* CaplAddinViews::GetAt(int ind)
//{
//	return m_Data.GetAt(ind);
//}
//
//void CaplAddinViews::SetFlagAt(int ind, bool show)
//{
//	m_Data.GetAt(ind)->show = show;
//}
//
//void CaplAddinViews::RemoveAt(int ind)
//{
//	if(ind<0)return;
//	if(ind>m_Data.GetSize()-1) return;
//	CaplViewInfo *vi = m_Data.GetAt(ind);
//	if(vi!=0) delete vi;
//	m_Data.RemoveAt(ind);
// }


//********************************************************************************************
//********************************************************************************************
//********************************************************************************************

CaplItemInfo::CaplItemInfo(aplAddInItemType type, LPCTSTR treeType, 
			 LPCTSTR menuName, LPCTSTR funcName, 
			 int image, int funcParamType, LPCTSTR descr)
{
	m_type= type;
	m_treeItemType= treeType;
	m_menuName= menuName;
	m_functionName= funcName;
	m_image= image;
	m_funcParamType= funcParamType;
	m_description = descr;
}

CaplItemInfo::CaplItemInfo(const CaplItemInfo &item)
{
	m_type= item.m_type;
	m_treeItemType= item.m_treeItemType;
	m_menuName= item.m_menuName;
	m_functionName= item.m_functionName;
	m_image= item.m_image;
	m_funcParamType= item.m_funcParamType;
	m_description = item.m_description;
}

//********************************************************************************************
//********************************************************************************************
//********************************************************************************************


CaplAddinViews::CaplAddinViews()
{
	m_Data.RemoveAll();
}

CaplAddinViews::~CaplAddinViews()
{
	DeleteAllViews();
}
void CaplAddinViews::AddView(CView*view, DWORD type, int pos, CString name, CString descr, bool show , long viewtype, long viewid)
{
	CaplViewInfo* vi = new CaplViewInfo;
	vi->pos = pos;
	vi->tab_name = name;
	vi->tab_descr = descr;
	vi->type = type;
	vi->view = view;
	vi->show =	 show;
	vi->viewtype= viewtype;
	vi->viewid= viewid;
	m_Data.Add(vi);
}

void CaplAddinViews::DeleteAllViews()
{
	while(m_Data.GetSize()>0)
	{
		CaplViewInfo *vi = m_Data.GetAt(0);
		if(vi!=0)
		{
			delete vi;
		}
		m_Data.RemoveAt(0);
	}
}

int CaplAddinViews::GetSize() 
{
	return m_Data.GetSize();
}

int CaplAddinViews::GetPos(int ind)
{
	if(ind<0 || ind>=GetSize()) return -1;
	CaplViewInfo* vi = m_Data.GetAt(ind);
	return vi->pos;
}

CaplViewInfo* CaplAddinViews::GetAt(int ind)
{
	return m_Data.GetAt(ind);
}

void CaplAddinViews::SetFlagAt(int ind, bool show)
{
	m_Data.GetAt(ind)->show = show;
}

void CaplAddinViews::RemoveAt(int ind)
{
	if(ind<0)return;
	if(ind>m_Data.GetSize()-1) return;
	CaplViewInfo *vi = m_Data.GetAt(ind);
	if(vi!=0) delete vi;
	m_Data.RemoveAt(ind);
}

