// SSWhatDlg.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "SSWhatDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSSWhatDlg dialog
BOOL CSSWhatDlg::s_acver = FALSE;
int CSSWhatDlg::s_what = 2;


CSSWhatDlg::CSSWhatDlg(CWnd* pParent /*=NULL*/)
	: CaplTranslateDialog(CSSWhatDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSSWhatDlg)
//	m_what = 2;
//	m_acver = FALSE;
	m_doc = _T("");
	m_disc_doc = _T("");
	//}}AFX_DATA_INIT
}


void CSSWhatDlg::DoDataExchange(CDataExchange* pDX)
{
	CaplTranslateDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSSWhatDlg)
	DDX_Control(pDX, IDC_CANCEL, m_cancel_btn);
	DDX_Control(pDX, IDOK, m_ok_btn);
	DDX_Control(pDX, IDC_SHOW_PROP, m_prop_btn);
	DDX_Control(pDX, IDC_ACTIVETEVER, m_av_check);
	DDX_Control(pDX, IDC_NEW_VER, m_newver);
	DDX_Radio(pDX, IDC_SCIP, m_what);
	DDX_Check(pDX, IDC_ACTIVETEVER, m_acver);
	DDX_Text(pDX, IDC_FIND_DOC, m_doc);
	DDX_Text(pDX, IDC_DOC_DISK, m_disc_doc);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSSWhatDlg, CaplTranslateDialog)
	//{{AFX_MSG_MAP(CSSWhatDlg)
	ON_BN_CLICKED(IDC_SHOW_PROP, OnShowProp)
	ON_BN_CLICKED(IDC_NEW_VER, OnNewVer)
	ON_BN_CLICKED(IDC_NEW_PROP, OnNewProp)
	ON_BN_CLICKED(IDC_SCIP, OnScip)
	ON_BN_CLICKED(IDC_CANCEL, OnCancel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSSWhatDlg message handlers

void CSSWhatDlg::OnShowProp() 
{
	m_api->m_doc_mgr.ShowDocProperties(m_doc_db);
}

BOOL CSSWhatDlg::OnInitDialog() 
{
	CaplTranslateDialog::OnInitDialog();

	if(m_api==0 || m_doc_db==0) 
	{
		EndDialog(0);
		return FALSE;
	}
	m_api->GetItemName(m_doc_db,m_doc);
	m_cancel_btn.SetIcon(GetAplStdIco16(APLSTDICO_CANCEL));
	m_cancel_btn.SetFlat(FALSE);
	m_ok_btn.SetIcon(GetAplStdIco16(APLSTDICO_OK));
	m_ok_btn.SetFlat(FALSE);
	m_prop_btn.SetIcon(GetAplTableIco(APL_TABLE_PROP));
	m_prop_btn.SetFlat(FALSE);
	m_av_check.EnableWindow(FALSE);
	if(m_lock)
		m_newver.EnableWindow(FALSE);
	if(m_what==1 && !m_lock)
		m_av_check.EnableWindow();

	else if(m_lock)
		m_what = 2;
	m_acver = s_acver;
	m_what = s_what;		
	UpdateData(FALSE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSSWhatDlg::OnNewVer() 
{
	m_av_check.EnableWindow(TRUE);
}

void CSSWhatDlg::OnNewProp() 
{
	m_av_check.EnableWindow(FALSE);
}

void CSSWhatDlg::OnScip() 
{
	m_av_check.EnableWindow(FALSE);
}

void CSSWhatDlg::OnCancel() 
{
	CaplTranslateDialog::OnCancel();
}

void CSSWhatDlg::OnOK() 
{
	UpdateData();
	s_acver = m_acver;
	s_what = m_what;		
	
	CaplTranslateDialog::OnOK();
}
