// PlotProperties.cpp : implementation file
#include "stdafx.h"
#include "GratingCalculator.h"
#include "PlotProperties.h"
// CPlotProperties dialog
IMPLEMENT_DYNAMIC(CPlotProperties, CDialog)
CPlotProperties::CPlotProperties(CWnd* pParent /*=NULL*/)
: CDialog(CPlotProperties::IDD, pParent)
{
m_NSerie = 0;
}
CPlotProperties::~CPlotProperties()
{
}
void CPlotProperties::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_LINE_PENSTYLE, m_combo_Line_PenStyle);
DDX_Control(pDX, IDC_COMBO_LINE_LINEWIDTH, m_combo_Line_LineWidth);
DDX_Control(pDX, IDC_COMBO_POINTS_STYLE, m_combo_Points_Style);
DDX_Control(pDX, IDC_COMBO_POINTS_HEIGHT, m_combo_Points_Height);
DDX_Control(pDX, IDC_COMBO_POINTS_WIDTH, m_combo_Points_Width);
DDX_Control(pDX, IDC_COMBO_SERIESNO, m_comboSeriesNo);
}
BEGIN_MESSAGE_MAP(CPlotProperties, CDialog)
ON_CBN_SELCHANGE(IDC_COMBO_LINE_PENSTYLE, &CPlotProperties::OnCbnSelchangeComboLinePenstyle)
ON_CBN_SELCHANGE(IDC_COMBO_LINE_LINEWIDTH, &CPlotProperties::OnCbnSelchangeComboLineLinewidth)
ON_CBN_SELCHANGE(IDC_COMBO_POINTS_STYLE, &CPlotProperties::OnCbnSelchangeComboPointsStyle)
ON_CBN_SELCHANGE(IDC_COMBO_POINTS_HEIGHT, &CPlotProperties::OnCbnSelchangeComboPointsHeight)
ON_CBN_SELCHANGE(IDC_COMBO_POINTS_WIDTH, &CPlotProperties::OnCbnSelchangeComboPointsWidth)
ON_CBN_SELCHANGE(IDC_COMBO_SERIESNO, &CPlotProperties::OnCbnSelchangeComboSeriesNo)
END_MESSAGE_MAP()
// CPlotProperties message handlers
void CPlotProperties::OnCbnSelchangeComboLinePenstyle()
{
int nIndex = -1;
nIndex = m_combo_Line_PenStyle.GetCurSel();
int nValue = -1;
nValue = (int) m_combo_Line_PenStyle.GetItemData(nIndex);
if ( nValue != -1 )
m_nPenStyle[m_NSerie] = nValue;
}
void CPlotProperties::OnCbnSelchangeComboLineLinewidth()
{
int nIndex = -1;
nIndex = m_combo_Line_LineWidth.GetCurSel();
int nValue = -1;
nValue = (int) m_combo_Line_LineWidth.GetItemData(nIndex);
if ( nValue != -1 )
m_nLineWidth[m_NSerie] = nValue;
}
void CPlotProperties::OnCbnSelchangeComboPointsStyle()
{
int nIndex = -1;
nIndex = m_combo_Points_Style.GetCurSel();
int nValue = -1;
nValue = (int) m_combo_Points_Style.GetItemData(nIndex);
if ( nValue != -1 )
m_nPointsType[m_NSerie] = nValue;
}
void CPlotProperties::OnCbnSelchangeComboPointsHeight()
{
int nIndex = -1;
nIndex = m_combo_Points_Height.GetCurSel();
int nValue = -1;
nValue = (int) m_combo_Points_Height.GetItemData(nIndex);
if ( nValue != -1 )
m_nPointsHeight[m_NSerie] = nValue;
}
void CPlotProperties::OnCbnSelchangeComboPointsWidth()
{
int nIndex = -1;
nIndex = m_combo_Points_Width.GetCurSel();
int nValue = -1;
nValue = (int) m_combo_Points_Width.GetItemData(nIndex);
if ( nValue != -1 )
m_nPointsWidth[m_NSerie] = nValue;
}
void CPlotProperties::OnCancel()
{
// Place Holder for verifications
CDialog::OnCancel();
}
BOOL CPlotProperties::PreTranslateMessage(MSG* pMsg)
{
return CDialog::PreTranslateMessage(pMsg);
}
void CPlotProperties::OnOK()
{
// Place Holder for verifications
CDialog::OnOK();
}
BOOL CPlotProperties::OnInitDialog()
{
CDialog::OnInitDialog();
m_NSerie = 0;
int nIndex = -1;
CString szFormat;
for (int k=0; k<MAX_SERIES_NO; k++)
{
szFormat.Format(_T("%03d"),k);
m_comboSeriesNo.AddString(szFormat.GetBuffer());
szFormat.ReleaseBuffer();
m_comboSeriesNo.SetCurSel(k);
nIndex = m_comboSeriesNo.GetCurSel();
m_comboSeriesNo.SetItemData(nIndex,(DWORD_PTR) k);
}
m_comboSeriesNo.SetCurSel(0);
// Set up the combos:
// Line LineWidth
int nLineWidth = 1;
while ( nLineWidth <= 10 )
{
szFormat.Format(_T("%02d"),nLineWidth);
m_combo_Line_LineWidth.AddString(szFormat.GetBuffer());
szFormat.ReleaseBuffer();
m_combo_Line_LineWidth.SetCurSel(nLineWidth-1);
nIndex = m_combo_Line_LineWidth.GetCurSel();
m_combo_Line_LineWidth.SetItemData(nIndex,(DWORD_PTR) nLineWidth);
nLineWidth++;
}
// Line Pen Style
int nPen = 0;
m_combo_Line_PenStyle.AddString(_T("PS_SOLID"));
m_combo_Line_PenStyle.SetCurSel(nPen);
nIndex = m_combo_Line_PenStyle.GetCurSel();
m_combo_Line_PenStyle.SetItemData(nIndex,(DWORD_PTR) PS_SOLID);
m_combo_Line_PenStyle.AddString(_T("PS_DASH"));
m_combo_Line_PenStyle.SetCurSel(++nPen);
nIndex = m_combo_Line_PenStyle.GetCurSel();
m_combo_Line_PenStyle.SetItemData(nIndex,(DWORD_PTR) PS_DASH);
m_combo_Line_PenStyle.AddString(_T("PS_DOT"));
m_combo_Line_PenStyle.SetCurSel(++nPen);
nIndex = m_combo_Line_PenStyle.GetCurSel();
m_combo_Line_PenStyle.SetItemData(nIndex,(DWORD_PTR) PS_DOT);
m_combo_Line_PenStyle.AddString(_T("PS_DASHDOT"));
m_combo_Line_PenStyle.SetCurSel(++nPen);
nIndex = m_combo_Line_PenStyle.GetCurSel();
m_combo_Line_PenStyle.SetItemData(nIndex,(DWORD_PTR) PS_DASHDOT);
m_combo_Line_PenStyle.AddString(_T("PS_DASHDOTDOT"));
m_combo_Line_PenStyle.SetCurSel(++nPen);
nIndex = m_combo_Line_PenStyle.GetCurSel();
m_combo_Line_PenStyle.SetItemData(nIndex,(DWORD_PTR) PS_DASHDOTDOT);
// Points styles
int nPtStyle = 0;
m_combo_Points_Style.AddString(_T("Ellipse"));
m_combo_Points_Style.SetCurSel(nPtStyle);
nIndex = m_combo_Points_Style.GetCurSel();
m_combo_Points_Style.SetItemData(nIndex,(DWORD_PTR) nPtStyle);
m_combo_Points_Style.AddString(_T("Rectangle"));
m_combo_Points_Style.SetCurSel(++nPtStyle);
nIndex = m_combo_Points_Style.GetCurSel();
m_combo_Points_Style.SetItemData(nIndex,(DWORD_PTR) nPtStyle);
m_combo_Points_Style.AddString(_T("Triangle"));
m_combo_Points_Style.SetCurSel(++nPtStyle);
nIndex = m_combo_Points_Style.GetCurSel();
m_combo_Points_Style.SetItemData(nIndex,(DWORD_PTR) nPtStyle);
// Points Width
int nPtWidth = 1;
while ( nPtWidth <= 10 )
{
szFormat.Format(_T("%02d"),nPtWidth);
m_combo_Points_Width.AddString(szFormat.GetBuffer());
szFormat.ReleaseBuffer();
m_combo_Points_Width.SetCurSel(nPtWidth-1);
nIndex = m_combo_Points_Width.GetCurSel();
m_combo_Points_Width.SetItemData(nIndex,(DWORD_PTR) nPtWidth);
nPtWidth++;
}
int nPtHeight = 1;
while ( nPtHeight <= 10 )
{
szFormat.Format(_T("%02d"),nPtHeight);
m_combo_Points_Height.AddString(szFormat.GetBuffer());
szFormat.ReleaseBuffer();
m_combo_Points_Height.SetCurSel(nPtHeight-1);
nIndex = m_combo_Points_Height.GetCurSel();
m_combo_Points_Height.SetItemData(nIndex,(DWORD_PTR) nPtHeight);
nPtHeight++;
}
// Set defaults in combos
int nValue;
for(int i=0; i<m_combo_Line_LineWidth.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Line_LineWidth.GetItemData(i);
if ( nValue == m_nLineWidth[0] )
{
m_combo_Line_LineWidth.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Line_PenStyle.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Line_PenStyle.GetItemData(i);
if ( nValue == m_nPenStyle[0] )
{
m_combo_Line_PenStyle.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Points_Style.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Points_Style.GetItemData(i);
if ( nValue == m_nPointsType[0] )
{
m_combo_Points_Style.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Points_Width.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Points_Width.GetItemData(i);
if ( nValue == m_nPointsWidth[0] )
{
m_combo_Points_Width.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Points_Height.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Points_Height.GetItemData(i);
if ( nValue == m_nPointsHeight[0] )
{
m_combo_Points_Height.SetCurSel(i);
break;
}
}
m_combo_Line_PenStyle.EnableWindow(TRUE);
m_combo_Line_LineWidth.EnableWindow(TRUE);
m_combo_Points_Style.EnableWindow(FALSE);
m_combo_Points_Height.EnableWindow(FALSE);
m_combo_Points_Width.EnableWindow(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPlotProperties::OnCbnSelchangeComboSeriesNo()
{
int nIndex = -1;
nIndex = m_comboSeriesNo.GetCurSel();
int nValue = -1;
nValue = (int) m_comboSeriesNo.GetItemData(nIndex);
m_NSerie = nValue;
if ( nValue%2 == 0 ) // lines
{
m_combo_Line_PenStyle.EnableWindow(TRUE);
m_combo_Line_LineWidth.EnableWindow(TRUE);
m_combo_Points_Style.EnableWindow(FALSE);
m_combo_Points_Height.EnableWindow(FALSE);
m_combo_Points_Width.EnableWindow(FALSE);
}
else // points
{
m_combo_Line_PenStyle.EnableWindow(FALSE);
m_combo_Line_LineWidth.EnableWindow(FALSE);
m_combo_Points_Style.EnableWindow(TRUE);
m_combo_Points_Height.EnableWindow(TRUE);
m_combo_Points_Width.EnableWindow(TRUE);
}
// Set defaults in combos
for(int i=0; i<m_combo_Line_LineWidth.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Line_LineWidth.GetItemData(i);
if ( nValue == m_nLineWidth[m_NSerie] )
{
m_combo_Line_LineWidth.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Line_PenStyle.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Line_PenStyle.GetItemData(i);
if ( nValue == m_nPenStyle[m_NSerie] )
{
m_combo_Line_PenStyle.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Points_Style.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Points_Style.GetItemData(i);
if ( nValue == m_nPointsType[m_NSerie] )
{
m_combo_Points_Style.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Points_Width.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Points_Width.GetItemData(i);
if ( nValue == m_nPointsWidth[m_NSerie] )
{
m_combo_Points_Width.SetCurSel(i);
break;
}
}
for(int i=0; i<m_combo_Points_Height.GetCount(); i++)
{
nValue = -1;
nValue = (int) m_combo_Points_Height.GetItemData(i);
if ( nValue == m_nPointsHeight[m_NSerie] )
{
m_combo_Points_Height.SetCurSel(i);
break;
}
}
}