You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
3.5 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//Îļþ: CScaleUnitPage.cpp
//Ö÷Òª¹¦ÄÜ:
//
//³ÌÐò±àд: 2006-12-07
//
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
//#include "DFDrawPro.h"
#include "ScaleUnitPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScaleUnitPage property page
IMPLEMENT_DYNCREATE(CScaleUnitPage, CPropertyPage)
CScaleUnitPage::CScaleUnitPage() : CPropertyPage(CScaleUnitPage::IDD)
{
//{{AFX_DATA_INIT(CScaleUnitPage)
m_bXnotY = FALSE;
m_xunitSel = 0;
m_yunitSel = 0;
msPerCM = 100.0;
//}}AFX_DATA_INIT
}
CScaleUnitPage::~CScaleUnitPage()
{
}
void CScaleUnitPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScaleUnitPage)
DDX_Check(pDX, IDC_CHECK_XY, m_bXnotY);
DDX_CBIndex(pDX, IDC_COMBO_xunit, m_xunitSel);
DDX_CBIndex(pDX, IDC_COMBO_yunit, m_yunitSel);
DDX_Text(pDX, IDC_EDIT_cm_ms, msPerCM);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScaleUnitPage, CPropertyPage)
//{{AFX_MSG_MAP(CScaleUnitPage)
ON_CBN_SELCHANGE(IDC_COMBO_yunit, OnSelchangeCOMBOyunit)
ON_CBN_SELCHANGE(IDC_COMBO_xunit, OnSelchangeCOMBOxunit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScaleUnitPage message handlers
void CScaleUnitPage::OnSelchangeCOMBOyunit()
{
UpdateData();
if(!m_bXnotY) m_xunitSel = m_yunitSel;
switch(m_yunitSel)
{
case 5:
case 6:
Show(TRUE);
break;
default:
Show(FALSE);
break;
}
UpdateData(FALSE);
}
void CScaleUnitPage::OnSelchangeCOMBOxunit()
{
UpdateData();
if(!m_bXnotY) m_yunitSel = m_xunitSel;
switch(m_yunitSel)
{
case 5:
case 6:
Show(TRUE);
break;
default:
Show(FALSE);
break;
}
UpdateData(FALSE);
}
double CScaleUnitPage::GetUnitX()
{
return GetUnit(m_xunitSel);
}
double CScaleUnitPage::GetUnitY()
{
return GetUnit(m_yunitSel);
}
/*
0 ¹«Àï kilometres
1 Ã× metre
2 ·ÖÃ× decimeter
3 ÀåÃ× centimeter
4 ºÁÃ× millimetres
5 Ãë second
6 ºÁÃë millisecond
7 Ó¢³ß foot = 304.8mm
8 Ó¢´ç inch = 25.4mm
9 Ó¢Àï mile = 1.609*1e6mm
10 Âë yard = 914.4mm
11 º£Àï nautical mile = 1852000mm
12 ¶íÀï Russian mile = 1.0668*1e6mm
13 ¶íÕÉ Russian unit of length = 2133.6mm
14 ÈÕÀï Japanese mile = 3.9273*1e6mm
15 ÈÕ³ß Japanese foot = 303mm;
*/
double CScaleUnitPage::GetUnit(int sel)//·µ»ØµÄµ¥Î»Îª ºÁÃ×
{
CUnit cu;
cu.msPerCM = msPerCM;
return cu.Millimetres((CUnit::EType)sel);
}
void CScaleUnitPage::Show(BOOL bFlag)
{
GetDlgItem(IDC_STATIC_cm)->ShowWindow(bFlag);
GetDlgItem(IDC_STATIC_ms)->ShowWindow(bFlag);
GetDlgItem(IDC_EDIT_cm_ms)->ShowWindow(bFlag);
}
BOOL CScaleUnitPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_psp.dwFlags &= ~PSH_HASHELP;
if(m_xunitSel==5 || m_xunitSel==6 || m_yunitSel==5 || m_yunitSel==6) Show(TRUE);
else Show(FALSE);
if(m_xunitSel != m_yunitSel) m_bXnotY = TRUE;
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CScaleUnitPage::OnSetActive()
{
CPropertySheet* pSheet = (CPropertySheet*)GetParent();
ASSERT_KINDOF(CPropertySheet, pSheet);
pSheet->SetWizardButtons(PSWIZB_NEXT);
return CPropertyPage::OnSetActive();
}
LRESULT CScaleUnitPage::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
return CPropertyPage::OnWizardNext();
}