// MagPropDlg.cpp : implementation file // #include "stdafx.h" #include "imgconvw.h" #include "MagPropDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMagPropDlg dialog CMagPropDlg::CMagPropDlg(LImageViewer *pImageViewer, CWnd* pParent /*=NULL*/) : CDialog(CMagPropDlg::IDD, pParent) { memset(&m_MagProp, 0, sizeof(DISPMAGACTIONPROPS)); m_MagProp.DispContainerActionProps.uStructSize = sizeof(DISPMAGACTIONPROPS); m_pImageViewer = pImageViewer; //{{AFX_DATA_INIT(CMagPropDlg) m_b3D = FALSE; m_bEllipes = FALSE; //}}AFX_DATA_INIT } void CMagPropDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMagPropDlg) DDX_Control(pDX, IDCMB_MAG_CROS, m_cmbCross); DDX_Control(pDX, IDEDT_MAG_ZOOM, m_edtZoom); DDX_Control(pDX, IDEDT_MAG_BORDER, m_edtBorder); DDX_Control(pDX, IDEDT_MAG_HEIGHT, m_edtHeight); DDX_Control(pDX, IDEDT_MAG_WIDTH, m_edtWidth); DDX_Check(pDX, IDCHK_MAG_3D, m_b3D); DDX_Check(pDX, IDCHK_MAG_ELPS, m_bEllipes); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CMagPropDlg, CDialog) //{{AFX_MSG_MAP(CMagPropDlg) ON_WM_PAINT() ON_BN_CLICKED(IDAPPLY, OnApply) ON_BN_CLICKED(IDBTN_MAG_PENCLR, OnMagPenClr) ON_BN_CLICKED(IDCHK_MAG_ELPS, OnMagEllipticalGlass) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMagPropDlg message handlers BOOL CMagPropDlg::OnInitDialog() { CDialog::OnInitDialog(); CString strVal; m_pImageViewer->GetActionProperties(CONTAINER_ACTION_MAG, 0, 0, (LONG)&m_MagProp, CONTAINER_ACTION_CONTAINERLEVEL); m_edtBorder.SetNumericEditBox(0, 10, 1, 0, FALSE); m_edtHeight.SetNumericEditBox(1, 1000, 1, 0, FALSE); m_edtWidth.SetNumericEditBox(1, 1000, 1, 0, FALSE); m_edtZoom.SetNumericEditBox(1, 1000, 1, 0, FALSE); m_b3D = m_MagProp.b3D; m_bEllipes = m_MagProp.bEllipse; strVal.Format(TEXT("%d"), m_MagProp.nBorderSize); m_edtBorder.SetWindowText(strVal); strVal.Format(TEXT("%d"), m_MagProp.nHeight); m_edtHeight.SetWindowText(strVal); strVal.Format(TEXT("%d"), m_MagProp.nWidth); m_edtWidth.SetWindowText(strVal); strVal.Format(TEXT("%d"), m_MagProp.nZoom); m_edtZoom.SetWindowText(strVal); m_cmbCross.AddString(TEXT("None")); m_cmbCross.AddString(TEXT("Fine")); m_cmbCross.AddString(TEXT("Invert Pen" )); m_cmbCross.AddString(TEXT("Invert Screen")); m_cmbCross.SetCurSel(m_MagProp.nCrosshair); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CMagPropDlg ::RepaintButton(L_INT id ,COLORREF ColorRef) { HBRUSH hNewBrush,hOldBrush; CDC *pcdc; RECT rect; PAINTSTRUCT ps; pcdc = GetDlgItem(id)->BeginPaint(&ps); GetDlgItem(id)->GetClientRect(&rect); hNewBrush = CreateSolidBrush (ColorRef); hOldBrush = (HBRUSH) SelectObject (pcdc->GetSafeHdc(), hNewBrush); Rectangle (pcdc->GetSafeHdc(), rect.left, rect.top, rect.right, rect.bottom); SelectObject(pcdc->GetSafeHdc(), hOldBrush); DeleteObject (hNewBrush); GetDlgItem(id)->EndPaint(&ps); } void CMagPropDlg::OnPaint() { CPaintDC dc(this); // device context for painting RepaintButton(IDSTC_MAG_PENCLR, m_MagProp.clrPen); // Do not call CDialog::OnPaint() for painting messages } void CMagPropDlg::OnApply() { CString strVal; UpdateData(TRUE); m_MagProp.b3D = m_b3D; m_MagProp.bEllipse = m_bEllipes; m_edtBorder.GetWindowText(strVal); m_MagProp.nBorderSize = _ttoi(strVal); m_edtHeight.GetWindowText(strVal); m_MagProp.nHeight = max(100, _ttoi(strVal)); m_edtWidth.GetWindowText(strVal); m_MagProp.nWidth = max(100, _ttoi(strVal)); m_edtZoom.GetWindowText(strVal); m_MagProp.nZoom = max(100, _ttoi(strVal)); m_MagProp.nCrosshair = m_cmbCross.GetCurSel(); m_pImageViewer->SetActionProperties(CONTAINER_ACTION_MAG, 0, 0, (LONG)&m_MagProp, CONTAINER_ACTION_CONTAINERLEVEL); UpdateData(FALSE); } void CMagPropDlg::OnOK() { OnApply(); CDialog::OnOK(); } void CMagPropDlg::OnMagPenClr() { m_MagProp.clrPen = ShowColorDlg(m_MagProp.clrPen); RedrawWindow(); } COLORREF CMagPropDlg:: ShowColorDlg (COLORREF crInitial) { LDialogColor DlgColor; COLORDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( COLORDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( COLORDLGPARAMS ) ; DlgParams.crColor = crInitial; DlgParams.uColorSpace = DLG_COLOR_COLORSPACE_SHOW_RGB; DlgParams.uDlgFlags = DLG_COLOR_SHOW_OLDCOLOR | DLG_COLOR_SHOW_NEWCOLOR | DLG_COLOR_SHOW_NAME | DLG_COLOR_COLORSPACE_SHOW_HUE | DLG_COLOR_COLORSPACE_SHOW_BRIGHTNESS | DLG_COLOR_COLORSPACE_SHOW_WHEEL | DLG_COLOR_COLORSPACE_SHOW_RGB | DLG_COLOR_COLORSPACE_SHOW_CMY | DLG_COLOR_COLORSPACE_SHOW_CMYK | DLG_COLOR_COLORSPACE_SHOW_LAB | DLG_COLOR_COLORMODEL_SHOW_RGB | DLG_COLOR_COLORMODEL_SHOW_HSB | DLG_COLOR_COLORMODEL_SHOW_HLS | DLG_COLOR_COLORMODEL_SHOW_CMY | DLG_COLOR_COLORMODEL_SHOW_CMYK | DLG_COLOR_COLORMODEL_SHOW_LAB ; DlgColor.SetColorParams(&DlgParams) ; DlgColor.DoModalColor(this->GetSafeHwnd()); // Gets the updated values for the structure DlgColor.GetColorParams(&DlgParams, sizeof(DlgParams)) ; return DlgParams.crColor; } void CMagPropDlg::OnMagEllipticalGlass() { UpdateData(TRUE); GetDlgItem(IDCHK_MAG_3D)->EnableWindow(!m_bEllipes); UpdateData(FALSE); }