// AlphaPropDlg.cpp : implementation file // #include "stdafx.h" #include "MSVC5conview.h" #include "AlphaPropDlg.h" #include "leadrastercontainercell.h" #include "leadalphaaction.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAlphaPropDlg dialog CAlphaPropDlg::CAlphaPropDlg(CWnd* pParent /*=NULL*/) : CDialog(CAlphaPropDlg::IDD, pParent) { //{{AFX_DATA_INIT(CAlphaPropDlg) m_uCellIndex = 0; m_uSensitivity = 0; m_uSubCellIndex = 0; m_nAlphaFactor = 0; m_bCircleMouse = FALSE; m_hIcon = NULL; //}}AFX_DATA_INIT } void CAlphaPropDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAlphaPropDlg) DDX_Control(pDX, IDC_ACTION_SEN_EDT, m_edtSensitivity); DDX_Control(pDX, IDC_ALPHAACTION_FACTOR_EDT, m_edtAlphaFactor); DDX_Control(pDX, IDC_ACTION_SUBCELLINDEX_EDT, m_edtSubCellIndex); DDX_Control(pDX, IDC_ACTION_CELLINDEX_EDT, m_edtCellIndex); DDX_Control(pDX, IDC_ACTION_SUBCELLINDEX_COM, m_cmbSubCellIndex); DDX_Control(pDX, IDC_ACTION_CUR_BTN, m_ActionCursor); DDX_Control(pDX, IDC_ACTION_CELLINDEX_COM, m_cmbCell); DDX_Control(pDX, IDC_ACTION_MOD_COM, m_cmbModifier); DDX_Control(pDX, IDC_ACTION_RIGHTKEY_COM, m_cmbRightKey); DDX_Control(pDX, IDC_ACTION_LEFTKEY_COM, m_cmbLeftKey); DDX_Text(pDX, IDC_ACTION_CELLINDEX_EDT, m_uCellIndex); DDX_Text(pDX, IDC_ACTION_SEN_EDT, m_uSensitivity); DDX_Text(pDX, IDC_ACTION_SUBCELLINDEX_EDT, m_uSubCellIndex); DDX_Text(pDX, IDC_ALPHAACTION_FACTOR_EDT, m_nAlphaFactor); DDX_Check(pDX, IDC_ACTION_CIRCLE_CHK, m_bCircleMouse); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAlphaPropDlg, CDialog) //{{AFX_MSG_MAP(CAlphaPropDlg) ON_BN_CLICKED(IDC_ACTION_CUR_BTN, OnActionCurBtn) ON_BN_CLICKED(IDAPPLY, OnApply) ON_EN_CHANGE(IDC_ACTION_CELLINDEX_EDT, OnChangeActionCellindexEdt) ON_CBN_SELCHANGE(IDC_ACTION_CELLINDEX_COM, OnSelchangeActionCellindexCom) ON_CBN_SELCHANGE(IDC_ACTION_SUBCELLINDEX_COM, OnSelchangeActionSubcellindexCom) ON_EN_CHANGE(IDC_ACTION_SUBCELLINDEX_EDT, OnChangeActionSubcellindexEdt) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CAlphaPropDlg message handlers void CAlphaPropDlg::OnActionCurBtn() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); if(pTheApp->GetIconFileName(m_FileName, (this->GetActiveWindow())->m_hWnd)) { m_hIcon = LoadCursorFromFile(m_FileName); m_ActionCursor.SetIcon(m_hIcon); } } void CAlphaPropDlg::OnApply() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); INT nVk; UINT uState = (8 >> (4 - m_cmbModifier.GetCurSel())); UpdateData(); m_pView->m_ConView.AlphaAction().SetCursor(pTheApp->hIconToIPictureDisp(m_hIcon)); m_pView->m_ConView.AlphaAction().SetCircularMouseMove(m_bCircleMouse); m_pView->m_ConView.AlphaAction().SetChange(m_uSensitivity); if(m_cmbCell.GetCurSel()) { INT nIndex; INT nSubIndex; if (m_cmbCell.GetCurSel() == 1) nIndex = -1; else nIndex = m_uCellIndex; if (m_cmbSubCellIndex.GetCurSel() == 0) nSubIndex = -1; else nSubIndex = m_uSubCellIndex; m_pView->m_ConView.AlphaAction().SetFactor(m_nAlphaFactor); m_pView->m_ConView.AlphaAction().SetAction(nIndex, nSubIndex, CONVIEW_ACTIONLEVEL_CELL); } nVk = pTheApp->GetVirtualKey(&m_cmbLeftKey); if (nVk != 0) { m_pView->m_ConView.AlphaAction().SetKey(nVk); m_pView->m_ConView.AlphaAction().SetModifier(uState); m_pView->m_ConView.AlphaAction().SetKeyboardAction(CONVIEW_MOUSEMOVE_LEFT); } nVk = pTheApp->GetVirtualKey(&m_cmbRightKey); if (nVk != 0) { m_pView->m_ConView.AlphaAction().SetKey(nVk); m_pView->m_ConView.AlphaAction().SetModifier(uState); m_pView->m_ConView.AlphaAction().SetKeyboardAction(CONVIEW_MOUSEMOVE_RIGHT); } m_pView->m_ConView.AlphaAction().SetAction(0,0, CONVIEW_ACTIONLEVEL_CONTAINER); } void CAlphaPropDlg::OnOK() { OnApply(); CDialog::OnOK(); } BOOL CAlphaPropDlg::OnInitDialog() { CDialog::OnInitDialog(); CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); INT nIndex = pTheApp->SearchForFirstSelectedCell(); nIndex = max(0, nIndex); m_pView->m_ConView.AlphaAction().GetAction(0, 0, CONVIEW_ACTIONLEVEL_CONTAINER); m_edtSensitivity.SetNumericEditBox(0, 100, 1, 0, 0); if(m_pView->m_ConView.GetCellCount()) { m_pView->m_ConView.AlphaAction().GetAction(nIndex, 0, CONVIEW_ACTIONLEVEL_CELL); m_uSubCellIndex = 0; m_uCellIndex = nIndex; m_nAlphaFactor = m_pView->m_ConView.AlphaAction().GetFactor(); m_edtCellIndex.SetNumericEditBox(0, m_pView->m_ConView.GetCellCount() - 1, 1, 0, 0); pTheApp->m_pRaster = (ILEADRaster *)m_pView->m_ConView.Cell(nIndex).GetBitmapList(); short nCount; pTheApp->m_pRaster->get_BitmapListCount(&nCount); m_edtSubCellIndex.SetNumericEditBox(0, nCount - 1, 1, 0, 0); m_edtAlphaFactor.SetNumericEditBox(-1000, 1000, 1, 0, 0); } m_cmbCell.AddString(TEXT("None")); m_cmbCell.AddString(TEXT("All")); m_cmbCell.AddString(TEXT("Custom")); m_cmbCell.SetCurSel(0); m_cmbSubCellIndex.AddString(TEXT("All")); m_cmbSubCellIndex.AddString(TEXT("Custom")); m_cmbSubCellIndex.SetCurSel(0); if(!m_pView->m_ConView.GetCellCount()) { (this->GetDlgItem(IDC_ACTION_CELLINDEX_COM))->EnableWindow(FALSE); (this->GetDlgItem(IDC_ACTION_SUBCELLINDEX_COM))->EnableWindow(FALSE); } (this->GetDlgItem(IDC_ACTION_SUBCELLINDEX_COM))->EnableWindow(FALSE); (this->GetDlgItem(IDC_ACTION_CELLINDEX_EDT))->EnableWindow(FALSE); (this->GetDlgItem(IDC_ACTION_SUBCELLINDEX_EDT))->EnableWindow(FALSE); (this->GetDlgItem(IDC_ALPHAACTION_FACTOR_EDT))->EnableWindow(FALSE); pTheApp->AddSupString(&m_cmbModifier); pTheApp->AddVirtualKeyString(&m_cmbLeftKey); pTheApp->AddVirtualKeyString(&m_cmbRightKey); m_pView->m_ConView.AlphaAction().GetKeyboardAction(CONVIEW_MOUSEMOVE_LEFT, 0); pTheApp->GetKeyboardInfo(&m_cmbLeftKey, &m_cmbModifier, m_pView->m_ConView.AlphaAction().GetKey(), m_pView->m_ConView.AlphaAction().GetModifier()); m_pView->m_ConView.AlphaAction().GetKeyboardAction(CONVIEW_MOUSEMOVE_RIGHT, 0); pTheApp->GetKeyboardInfo(&m_cmbRightKey, &m_cmbModifier, m_pView->m_ConView.AlphaAction().GetKey(), m_pView->m_ConView.AlphaAction().GetModifier()); m_bCircleMouse = m_pView->m_ConView.AlphaAction().GetCircularMouseMove(); m_uSensitivity = m_pView->m_ConView.AlphaAction().GetChange(); m_hIcon = pTheApp->IPictureDispTohIcon((IPictureDisp *)(m_pView->m_ConView.AlphaAction().GetCursor().m_lpDispatch)); m_ActionCursor.SetIcon( m_pView->m_ConView.AlphaAction().GetCursor() ? m_hIcon:LoadCursor(NULL, IDC_ARROW)); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CAlphaPropDlg::OnChangeActionCellindexEdt() { CConViewApp * pTheApp = (CConViewApp *)AfxGetApp(); UpdateData(); m_pView->m_ConView.AlphaAction().GetAction(m_uCellIndex, m_uSubCellIndex, CONVIEW_ACTIONLEVEL_CELL); m_nAlphaFactor = m_pView->m_ConView.AlphaAction().GetFactor(); pTheApp->m_pRaster = (ILEADRaster *)m_pView->m_ConView.Cell(m_uCellIndex).GetBitmapList(); short nCount; pTheApp->m_pRaster->get_BitmapListCount(&nCount); m_edtSubCellIndex.SetNumericEditBox(0, nCount - 1, 1, 0, 0); UpdateData(FALSE); } void CAlphaPropDlg::OnSelchangeActionCellindexCom() { INT nRet = m_cmbCell.GetCurSel(); GetDlgItem(IDC_ACTION_CELLINDEX_EDT)->EnableWindow(nRet == 2); GetDlgItem(IDC_ACTION_SUBCELLINDEX_COM)->EnableWindow((nRet != 0)); GetDlgItem(IDC_ACTION_SUBCELLINDEX_EDT)->EnableWindow((nRet != 0) && (m_cmbSubCellIndex.GetCurSel())); GetDlgItem(IDC_ALPHAACTION_FACTOR_EDT)->EnableWindow(nRet != 0); } void CAlphaPropDlg::OnSelchangeActionSubcellindexCom() { GetDlgItem(IDC_ACTION_SUBCELLINDEX_EDT)->EnableWindow((m_cmbSubCellIndex.GetCurSel() == 1)); } void CAlphaPropDlg::OnChangeActionSubcellindexEdt() { UpdateData(); m_pView->m_ConView.AlphaAction().GetAction(m_uCellIndex, m_uSubCellIndex, CONVIEW_ACTIONLEVEL_CELL); m_nAlphaFactor = m_pView->m_ConView.AlphaAction().GetFactor(); UpdateData(FALSE); }