#include "stdafx.h"
#include "INKS.h"
#include "ObjectInfoDialogBar.h"


IMPLEMENT_DYNAMIC(CObjectInfoDialogBar, CDialogBar)


CObjectInfoDialogBar::CObjectInfoDialogBar(CWnd* pParent /*=NULL*/)
	: CDialogBar()
{
	m_dbCurrent = NULL;
}

CObjectInfoDialogBar::~CObjectInfoDialogBar()
{
	m_Sub1.DestroyWindow();
	m_Sub2.DestroyWindow();
}

void CObjectInfoDialogBar::DoDataExchange(CDataExchange* pDX)
{
	CDialogBar::DoDataExchange(pDX);

}


BEGIN_MESSAGE_MAP(CObjectInfoDialogBar, CDialogBar)
	ON_WM_CREATE()
END_MESSAGE_MAP()

// CInnerDialog message handlers

static UINT infobarindicators[] =
{
	ID_XYMOUSEPOS,
	ID_SEPARATOR,
	ID_XYMOUSEPOSSNAPPED
};

BOOL CObjectInfoDialogBar::Create(CWnd* pParent, UINT nIDTemplate, UINT nStyle, UINT nID) 
{
	BOOL bReturn = CDialogBar::Create(pParent, nIDTemplate, nStyle, nID);
	//add your control initialization code here AFTER calling base class
	return bReturn;
}

int CObjectInfoDialogBar::OnCreate(LPCREATESTRUCT lpcs)
{
	if (CDialogBar::OnCreate(lpcs) == -1)
		return -1;
	m_Sub1.Create(IDD_OBJECTINFOSUBBAR1, this);
	m_Sub2.Create(IDD_OBJECTINFOSUBBAR2, this);
	m_Sub2.ShowWindow(SW_HIDE);
	m_Sub1.ShowWindow(SW_SHOW);

	if(!m_StatusBar.Create(WS_CHILD|WS_VISIBLE|SBT_OWNERDRAW,CRect(0,0,0,0), this, 0)){
		TRACE0("Failed to create status bar\n");
		return -1;
	}
	//int strPartDim[5]= {200, 80, -1, 80};
	//m_StatusBar.SetParts(4, strPartDim);
	//m_StatusBar.SetText(_T("ONE"), 0, 0);
	//m_StatusBar.SetText(_T("TWO"), 1, 0);
	int strPartDim[4]= {70, 140, 210, -1};
	m_StatusBar.SetParts(4, strPartDim);
	return 0;
}

void CObjectInfoDialogBar::ShowSubBar1()
{
	if(m_dbCurrent == &m_Sub1){
		return;
	}
	if(m_dbCurrent){
		m_dbCurrent->ShowWindow(SW_HIDE);
	}

	m_dbCurrent = &m_Sub1;
	m_dbCurrent->ShowWindow(SW_SHOW);
}

void CObjectInfoDialogBar::ShowSubBar2()
{
	if(m_dbCurrent == &m_Sub2){
		return;
	}
	if(m_dbCurrent){
		m_dbCurrent->ShowWindow(SW_HIDE);
	}

	m_dbCurrent = &m_Sub2;
	m_dbCurrent->ShowWindow(SW_SHOW);
}