// CellPropeDlg.cpp : implementation file // #include "stdafx.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCellPropDlg dialog CCellPropDlg::CCellPropDlg(LImageViewer * pImageViewer, CWnd* pParent /*=NULL*/) : CDialog(CCellPropDlg::IDD, pParent) { m_pImageViewer = pImageViewer; memset(&m_ImageViewerCellProps, 0, sizeof(m_ImageViewerCellProps)); m_ImageViewerCellProps.uStructSize = sizeof(m_ImageViewerCellProps); //{{AFX_DATA_INIT(CCellPropDlg) m_bShowTag = FALSE; m_bFitImage = FALSE; m_bApplyAll = FALSE; m_bMove = FALSE; m_nApplyCellType = -1; //}}AFX_DATA_INIT } void CCellPropDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCellPropDlg) DDX_Control(pDX, IDCMB_CELLPROP_SHOWRULER, m_cmbShowRuler); DDX_Control(pDX, IDEDT_CELLPROP_COLS, m_edtCols); DDX_Control(pDX, IDEDT_CELLPROP_ROWS, m_edtRows); DDX_Check(pDX, IDCHK_CELLPROP_SHOWTAG, m_bShowTag); DDX_Check(pDX, IDCHK_CELLPROP_FITIMG, m_bFitImage); DDX_Check(pDX, IDCHK_CELLPROP_APPLYONALL, m_bApplyAll); DDX_Check(pDX, IDCHK_CELLPROP_ONMOVE, m_bMove); DDX_Radio(pDX, IDRAD_CELLPROP_ALLCELLS, m_nApplyCellType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCellPropDlg, CDialog) //{{AFX_MSG_MAP(CCellPropDlg) ON_BN_CLICKED(IDAPPLY, OnApply) ON_BN_CLICKED(IDRESET, OnReset) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCellPropDlg message handlers BOOL CCellPropDlg::OnInitDialog() { CDialog::OnInitDialog(); UpdateData(TRUE); L_INT nIndex; CString strVal; L_INT nCount = (m_pImageViewer ? m_pImageViewer->GetCellCount(0) : 0); for (nIndex = 0; nIndex < nCount; nIndex++) { if(m_pImageViewer) { if (m_pImageViewer->IsCellSelected(nIndex,0)) break; } } if (nIndex == nCount) nIndex = -1; m_ImageViewerCellProps.uMask = DCCELLPF_ALL; m_pImageViewer->GetCellProperties(max(0,nIndex), &m_ImageViewerCellProps,0); strVal.Format(TEXT("%d"), m_ImageViewerCellProps.uNumRows); m_edtRows.SetWindowText(strVal); strVal.Format(TEXT("%d"), m_ImageViewerCellProps.uNumCols); m_edtCols.SetWindowText(strVal); m_bShowTag = (m_ImageViewerCellProps.uShowTags == DCCELLPF_SHOWTAGS_SHOW)? TRUE : FALSE; m_bFitImage = m_ImageViewerCellProps.bIsFit; m_bMove = m_ImageViewerCellProps.bOnMove; m_bApplyAll = !m_ImageViewerCellProps.bIndividual; m_cmbShowRuler.AddString(TEXT("None")); m_cmbShowRuler.AddString(TEXT("Both")); m_cmbShowRuler.AddString(TEXT("Vertical")); m_cmbShowRuler.AddString(TEXT("Horizontal")); m_cmbShowRuler.SetCurSel(m_ImageViewerCellProps.uShowRuler); m_edtRows.SetNumericEditBox(1, 4, 1, 0, 0); m_edtCols.SetNumericEditBox(1, 8, 1, 0, 0); if (nIndex < 0) { m_nApplyCellType = 0; GetDlgItem(IDRAD_CELLPROP_SELECTED)->EnableWindow(FALSE); } else m_nApplyCellType = 1; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CCellPropDlg::OnApply() { CString strVal; UpdateData(TRUE); m_edtRows.GetWindowText(strVal); m_ImageViewerCellProps.uNumRows = _ttoi(strVal); m_edtCols.GetWindowText(strVal); m_ImageViewerCellProps.uNumCols = _ttoi(strVal); m_ImageViewerCellProps.uShowRuler = m_cmbShowRuler.GetCurSel(); m_ImageViewerCellProps.bIndividual = !m_bApplyAll; m_ImageViewerCellProps.bIsFit = m_bFitImage; m_ImageViewerCellProps.bOnMove = m_bMove; m_ImageViewerCellProps.uShowTags = m_bShowTag ? DCCELLPF_SHOWTAGS_SHOW : DCCELLPF_SHOWTAGS_HIDE; m_ImageViewerCellProps.uShowRuler = m_cmbShowRuler.GetCurSel(); if(m_nApplyCellType) { L_INT nCount = (m_pImageViewer ? m_pImageViewer->GetCellCount(0) : 0); for (L_INT nI = 0; nI < nCount; nI++) { if(m_pImageViewer) { if (m_pImageViewer->IsCellSelected(nI, 0)) { m_pImageViewer->SetCellProperties(nI, &m_ImageViewerCellProps, 0); } } } } else { int nRet = m_pImageViewer->SetCellProperties(-1, &m_ImageViewerCellProps,0); } UpdateData(FALSE); } void CCellPropDlg::OnOK() { OnApply(); CDialog::OnOK(); } void CCellPropDlg::OnReset() { CString strVal; UpdateData(TRUE); m_ImageViewerCellProps.uShowRuler = DCCELLPF_SHOWRULER_BOTH; m_cmbShowRuler.SetCurSel(m_ImageViewerCellProps.uShowRuler); m_ImageViewerCellProps.uNumRows = 1; strVal.Format(TEXT("%d"), m_ImageViewerCellProps.uNumRows); m_edtRows.SetWindowText(strVal); m_ImageViewerCellProps.uNumCols = 1; strVal.Format(TEXT("%d"), m_ImageViewerCellProps.uNumCols); m_edtCols.SetWindowText(strVal); m_ImageViewerCellProps.uShowTags = DCCELLPF_SHOWTAGS_SHOW; m_bShowTag = (m_ImageViewerCellProps.uShowTags == DCCELLPF_SHOWTAGS_SHOW)? TRUE : FALSE; m_ImageViewerCellProps.bIsFit = TRUE; m_bFitImage = m_ImageViewerCellProps.bIsFit; m_ImageViewerCellProps.bOnMove = FALSE; m_bMove = m_ImageViewerCellProps.bOnMove; m_ImageViewerCellProps.bIndividual = FALSE; m_bApplyAll = !m_ImageViewerCellProps.bIndividual; if(m_nApplyCellType) { L_INT nCount = (m_pImageViewer ? m_pImageViewer->GetCellCount(0) : 0); for (L_INT nI = 0; nI < nCount; nI++) { if(m_pImageViewer) { if (m_pImageViewer->IsCellSelected(nI, 0)) { m_pImageViewer->SetCellProperties(nI, &m_ImageViewerCellProps, 0); } } } } else { int nRet = m_pImageViewer->SetCellProperties(-1, &m_ImageViewerCellProps,0); } UpdateData(FALSE); }