/*********************************************************/
//	NkILSamplePropertySheet.cpp
//		Source file of ImageInfo PropertySheet class.
//
//	Copyright(c) 2007, Nikon Corporation - All rights reserved.
/*********************************************************/

#include "stdafx.h"
#include "NkILSamplePropertySheet.h"
#include "NkILSample.h"

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

// CNkILSamplePropertySheet

IMPLEMENT_DYNAMIC(CNkILSamplePropertySheet, CPropertySheet)

CNkILSamplePropertySheet::CNkILSamplePropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
	m_psh.dwFlags |= (PSH_NOAPPLYNOW);			// disable Apply button
	m_pParent = pParentWnd;
	AddAllPage();								// add propertypage to propertysheet
}

CNkILSamplePropertySheet::CNkILSamplePropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
	:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	m_psh.dwFlags |= (PSH_NOAPPLYNOW);			// disable Apply button
	m_pParent = pParentWnd;
	AddAllPage();								// add propertypage to propertysheet
}

CNkILSamplePropertySheet::~CNkILSamplePropertySheet()
{
}


BEGIN_MESSAGE_MAP(CNkILSamplePropertySheet, CPropertySheet)
END_MESSAGE_MAP()

//////////////////////////////////////////////////////////////////
// OnInitDialog
BOOL CNkILSamplePropertySheet::OnInitDialog()
{	
	CPropertySheet::OnInitDialog();
	// get propertysheet cordinate in screen
	CRect rcDlg, rcTab, rcCtrl;	
	GetWindowRect( rcDlg );

	// get control pointer
	CTabCtrl* pTab = GetTabControl();
	CPropertyPage *pActive = GetActivePage();
	if( NULL == pTab || NULL == pActive )
		return FALSE;

	// calclate blank between propertysheet and propertypage
	pTab->GetWindowRect( rcTab );	// get tab cordinate in screen
	int nBlankToPropPage = rcTab.left - rcDlg.left;

	// calclate blank between propertypage and control
	CStatic* pStatic = (CStatic*)pActive->GetDlgItem(IDC_STATIC_GROUPBASE);
	pStatic->GetWindowRect(rcCtrl);
	int nBlankToCtrl = rcCtrl.left - rcTab.left;

	// adjust size
	rcTab.right = rcCtrl.right + nBlankToCtrl;
	rcDlg.right = rcTab.right + nBlankToPropPage;

	this->ScreenToClient( rcTab );	// convert cordinate in dialog

	// set cordinate 
	MoveWindow( rcDlg );
	pTab->MoveWindow( rcTab );

	// update property page
	SetActivePage(pActive);
	
	return TRUE;
}
// OnInitDialog
//////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////
// PostNcDestroy
void CNkILSamplePropertySheet::PostNcDestroy()
{
	if( m_pParent != NULL )
	{
		m_pParent->SendMessage( MSG_WM_DELETE_INFODLG );	// send message for delete dialog	
	}
}
// PostNcDestroy
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
// AddAllPage
void CNkILSamplePropertySheet::AddAllPage()
{
	// add each propertypage to propertysheet
	AddPage( &m_ImgInfoPage );
	AddPage( &m_ThumbInfoPage );
	AddPage( &m_CameraInfoPage );
}
// AddAllPage
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
// SetAllPageInfo
void CNkILSamplePropertySheet::SetAllPageInfo(unsigned long ulFormat, NkIL_ImageInfo StrImageInfo, NkIL_ImageInfo StrOrgImageInfo, 
										  VECTTHUMBINFO vecThumbInfo, VECTCAMERAINFO vecCameraInfo)
{
	// set info to Image/File info dialog
	m_ImgInfoPage.SetInfomation( ulFormat, StrImageInfo, StrOrgImageInfo );
	// set info to Thubmnail info dialog
	m_ThumbInfoPage.SetInfomation( vecThumbInfo );
	// set info to Shooting info dialog
	m_CameraInfoPage.SetInfomation( vecCameraInfo );
}
// SetAllPageInfo
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
// UpdateImageInfoPage
void CNkILSamplePropertySheet::UpdateImageInfoPage()
{
	// update all info of imageinfopage	
	m_ImgInfoPage.UpdateData(false);	
}
// UpdateImageInfoPage
//////////////////////////////////////////////////////////////////