// ZoomViewOptionsDlg.cpp : implementation file // #include "stdafx.h" #include "ZoomView.h" #include "ZoomViewOptionsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CZoomViewOptionsDlg dialog CZoomViewOptionsDlg::CZoomViewOptionsDlg(pZOOMVIEWPROPS pZoomView, CWnd* pParent) : CDialog(CZoomViewOptionsDlg::IDD, pParent) { m_ZoomViewBorderStyle = 0; if (pZoomView) { m_pZoomView = pZoomView; } } CZoomViewOptionsDlg::~CZoomViewOptionsDlg() { } void CZoomViewOptionsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CZoomViewOptionsDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CZoomViewOptionsDlg, CDialog) //{{AFX_MSG_MAP(CZoomViewOptionsDlg) ON_BN_CLICKED(IDBTN_ZOOMVIEW_SRCCOLOR, OnZoomViewSrcColor) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_SRCAPPEARANCE, OnSrcAppearanceChange) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_SRCPEN, OnZoomViewSrcPenChange) ON_BN_CLICKED(IDBTN_ZOOMVIEW_DSTCOLOR, OnZoomViewDstColor) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_DSTPEN, OnZoomViewDstPenChange) ON_BN_CLICKED(IDCHK_ZOOMVIEW_CALLOUTS, OnZoomViewCallouts) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_CALLOUTPEN, OnZoomViewCalloutPenChange) ON_WM_DRAWITEM() ON_BN_CLICKED(IDBTN_ZOOMVIEW_CALLOUTCOLOR, OnZoomviewCalloutcolor) ON_EN_KILLFOCUS(IDEDT_ZOOMVIEW_ZOOMFACTOR, OnKillfocusZoomFactor) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_DSTAPPEARANCE, OnSelChangeDstAppearance) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_DSTBORDERSTYLE, OnSelChangeDstBorderStyle) ON_CBN_SELCHANGE(IDCMB_ZOOMVIEW_DSTSHAPE, OnSelChangeDstShape) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZoomViewOptionsDlg message handlers BOOL CZoomViewOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); { FillPenCombo(IDCMB_ZOOMVIEW_SRCPEN, m_pZoomView->nSrcPenStyle); FillPenCombo(IDCMB_ZOOMVIEW_DSTPEN, m_pZoomView->nZoomViewPenStyle); FillPenCombo(IDCMB_ZOOMVIEW_CALLOUTPEN, m_pZoomView->nCalloutPenStyle); FillBorderStyleCombo(IDCMB_ZOOMVIEW_DSTBORDERSTYLE, m_pZoomView->uZoomViewBorderStyle); FillSrcAppearanceCombo(IDCMB_ZOOMVIEW_SRCAPPEARANCE,m_pZoomView->uSrcBorderStyle); FillDstAppearanceCombo(IDCMB_ZOOMVIEW_DSTAPPEARANCE, m_pZoomView->uZoomViewBorderStyle); FillShapeCombo(IDCMB_ZOOMVIEW_DSTSHAPE, m_pZoomView->uZoomViewBorderStyle); if(m_pZoomView->uSrcBorderStyle == SOURCEBORDERSTYLE_3D) { GetDlgItem(IDCMB_ZOOMVIEW_SRCPEN)->EnableWindow(FALSE); GetDlgItem(IDSTC_ZOOMVIEW_SRCPEN)->EnableWindow(FALSE); GetDlgItem(IDBTN_ZOOMVIEW_SRCCOLOR)->EnableWindow(FALSE); GetDlgItem(IDSTC_ZOOMVIEW_SRCCOLOR)->EnableWindow(FALSE); } if(m_pZoomView->bCallouts) { CheckDlgButton(IDCHK_ZOOMVIEW_CALLOUTS, BM_SETCHECK); } GetDlgItem(IDSTC_ZOOMVIEW_CALLOUTPEN)->EnableWindow(m_pZoomView->bCallouts); GetDlgItem(IDCMB_ZOOMVIEW_CALLOUTPEN)->EnableWindow(m_pZoomView->bCallouts); GetDlgItem(IDSTC_ZOOMVIEW_CALLOUTCOLOR)->EnableWindow(m_pZoomView->bCallouts); GetDlgItem(IDBTN_ZOOMVIEW_CALLOUTCOLOR)->EnableWindow(m_pZoomView->bCallouts); SetDlgItemInt (IDEDT_ZOOMVIEW_ZOOMFACTOR, m_pZoomView->nZoom, TRUE); } InitDstCombo(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CZoomViewOptionsDlg::OnOK() { int nValue; UpdateData(); nValue = (int)GetDlgItemInt(IDEDT_ZOOMVIEW_ZOOMFACTOR, NULL, FALSE); m_pZoomView->uZoomViewBorderStyle = 0; m_pZoomView->uZoomViewBorderStyle |= GetCurSelValue(IDCMB_ZOOMVIEW_DSTSHAPE); m_pZoomView->uZoomViewBorderStyle |= GetCurSelValue(IDCMB_ZOOMVIEW_DSTBORDERSTYLE); m_pZoomView->uZoomViewBorderStyle |= GetCurSelValue(IDCMB_ZOOMVIEW_DSTAPPEARANCE); m_pZoomView->nZoom = ValidateZoomFactor(nValue); UpdateData(FALSE); CDialog::OnOK(); } void CZoomViewOptionsDlg :: FillPenCombo(int id, int nPen) { CComboBox *pcmbTemp; pcmbTemp = (CComboBox*)GetDlgItem(id); pcmbTemp->AddString(TEXT("0 - Solid")); pcmbTemp->AddString(TEXT("1 - Dash")); pcmbTemp->AddString(TEXT("2 - Dot")); pcmbTemp->AddString(TEXT("3 - DashDot")); pcmbTemp->AddString(TEXT("4 - DASHDOTDOT")); pcmbTemp->SetItemData(0, PS_SOLID); pcmbTemp->SetItemData(1, PS_DASH); pcmbTemp->SetItemData(2, PS_DOT); pcmbTemp->SetItemData(3, PS_DASHDOT); pcmbTemp->SetItemData(4, PS_DASHDOTDOT); pcmbTemp->SetCurSel(nPen); } void CZoomViewOptionsDlg :: FillBorderStyleCombo(L_INT id, L_UINT uZoomViewBorderStyle) { BOOL bSimpleZoomView; CComboBox *pcmbTemp; pcmbTemp = (CComboBox*)GetDlgItem(id); pcmbTemp->AddString(TEXT("0 - None")); pcmbTemp->AddString(TEXT("1 - Fixed Single")); pcmbTemp->SetItemData(0, ZOOMVIEWBORDERSTYLE_NONE); pcmbTemp->SetItemData(1, ZOOMVIEWBORDERSTYLE_SIMPLE); bSimpleZoomView = uZoomViewBorderStyle & ZOOMVIEWBORDERSTYLE_SIMPLE; pcmbTemp->SetCurSel(bSimpleZoomView ? ZOOMVIEWBORDERSTYLE_SIMPLE : ZOOMVIEWBORDERSTYLE_NONE); } void CZoomViewOptionsDlg :: FillSrcAppearanceCombo(L_INT id, L_UINT uZoomViewBorderStyle) { CComboBox *pcmbTemp; pcmbTemp = (CComboBox*)GetDlgItem(id); BOOL b3D; pcmbTemp->AddString(TEXT("0 - Flat")); pcmbTemp->AddString(TEXT("1 - 3D")); pcmbTemp->SetItemData(0, SOURCEBORDERSTYLE_SIMPLE); pcmbTemp->SetItemData(1, SOURCEBORDERSTYLE_3D); b3D = uZoomViewBorderStyle & SOURCEBORDERSTYLE_3D; pcmbTemp->SetCurSel(b3D ? SOURCEBORDERSTYLE_3D : SOURCEBORDERSTYLE_SIMPLE); } void CZoomViewOptionsDlg :: FillDstAppearanceCombo(L_INT id, L_UINT uZoomViewBorderStyle) { CComboBox *pcmbTemp; pcmbTemp = (CComboBox*)GetDlgItem(id); BOOL b3D; pcmbTemp->AddString(TEXT("0 - Flat")); pcmbTemp->AddString(TEXT("2 - 3D")); pcmbTemp->SetItemData(0, ZOOMVIEWBORDERSTYLE_NONE); pcmbTemp->SetItemData(1, ZOOMVIEWBORDERSTYLE_3D); b3D = uZoomViewBorderStyle & ZOOMVIEWBORDERSTYLE_3D; pcmbTemp->SetCurSel(b3D ? 1 : 0); } void CZoomViewOptionsDlg :: FillShapeCombo(L_INT id, L_UINT uZoomViewBorderStyle) { CComboBox *pcmbTemp; pcmbTemp = (CComboBox*)GetDlgItem(id); pcmbTemp->AddString(TEXT("0 - Rectangle")); pcmbTemp->AddString(TEXT("4 - Tear Out")); pcmbTemp->AddString(TEXT("8 - Rounded Rectangle")); pcmbTemp->SetItemData(0, ZOOMVIEWBORDERSTYLE_NONE); pcmbTemp->SetItemData(1, ZOOMVIEWBORDERSTYLE_TEAROUT); pcmbTemp->SetItemData(2, ZOOMVIEWBORDERSTYLE_ROUNDED); pcmbTemp->SetCurSel(0); if(uZoomViewBorderStyle & ZOOMVIEWBORDERSTYLE_TEAROUT) pcmbTemp->SetCurSel(1); if(uZoomViewBorderStyle & ZOOMVIEWBORDERSTYLE_ROUNDED) pcmbTemp->SetCurSel(2); } COLORREF CZoomViewOptionsDlg :: ShowColorDlg (COLORREF crInitial) { LDialogColor DlgColor; COLORDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( COLORDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( COLORDLGPARAMS ) ; DlgParams.crColor = crInitial; 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; } L_INT CZoomViewOptionsDlg::GetCurSelValue(L_INT id) { L_INT nCurSel; CComboBox *pcmbTemp; pcmbTemp = (CComboBox*)GetDlgItem(id); nCurSel = pcmbTemp->GetCurSel(); return pcmbTemp->GetItemData(nCurSel); } void CZoomViewOptionsDlg::OnZoomViewSrcColor() { m_pZoomView->crSrcBorder = ShowColorDlg (m_pZoomView->crSrcBorder); RepaintButton(IDBTN_ZOOMVIEW_SRCCOLOR, m_pZoomView->crSrcBorder); } void CZoomViewOptionsDlg::OnSrcAppearanceChange() { BOOL b3D; m_pZoomView->uSrcBorderStyle = GetCurSelValue(IDCMB_ZOOMVIEW_SRCAPPEARANCE); b3D = (m_pZoomView->uSrcBorderStyle == SOURCEBORDERSTYLE_3D); GetDlgItem(IDCMB_ZOOMVIEW_SRCPEN)->EnableWindow(!b3D); GetDlgItem(IDSTC_ZOOMVIEW_SRCPEN)->EnableWindow(!b3D); GetDlgItem(IDBTN_ZOOMVIEW_SRCCOLOR)->EnableWindow(!b3D); GetDlgItem(IDSTC_ZOOMVIEW_SRCCOLOR)->EnableWindow(!b3D); } void CZoomViewOptionsDlg::OnZoomViewSrcPenChange() { m_pZoomView->nSrcPenStyle = GetCurSelValue(IDCMB_ZOOMVIEW_SRCPEN); } void CZoomViewOptionsDlg::OnZoomViewDstColor() { m_pZoomView->crZoomViewBorder = ShowColorDlg (m_pZoomView->crZoomViewBorder); RepaintButton(IDBTN_ZOOMVIEW_DSTCOLOR, m_pZoomView->crZoomViewBorder); } void CZoomViewOptionsDlg::OnZoomViewDstPenChange() { m_pZoomView->nZoomViewPenStyle = GetCurSelValue(IDCMB_ZOOMVIEW_DSTPEN); } void CZoomViewOptionsDlg::OnZoomViewCallouts() { m_pZoomView->bCallouts = !m_pZoomView->bCallouts; GetDlgItem(IDSTC_ZOOMVIEW_CALLOUTPEN)->EnableWindow(m_pZoomView->bCallouts); GetDlgItem(IDCMB_ZOOMVIEW_CALLOUTPEN)->EnableWindow(m_pZoomView->bCallouts); GetDlgItem(IDSTC_ZOOMVIEW_CALLOUTCOLOR)->EnableWindow(m_pZoomView->bCallouts); GetDlgItem(IDBTN_ZOOMVIEW_CALLOUTCOLOR)->EnableWindow(m_pZoomView->bCallouts); } void CZoomViewOptionsDlg::OnZoomViewCalloutPenChange() { m_pZoomView->nCalloutPenStyle = GetCurSelValue(IDCMB_ZOOMVIEW_CALLOUTPEN); } void CZoomViewOptionsDlg::RepaintButton(L_INT id ,COLORREF ColorRef) { HBRUSH hNewBrush,hOldBrush; CDC *pcdc; RECT rect; BOOL bEnable; pcdc = GetDlgItem(id)->GetDC(); GetDlgItem(id)->GetClientRect(&rect); bEnable = GetDlgItem(id)->IsWindowEnabled(); hNewBrush = CreateSolidBrush (bEnable ? ColorRef : GetSysColor(COLOR_BTNFACE)); hOldBrush = (HBRUSH) SelectObject (pcdc->GetSafeHdc(), hNewBrush); Rectangle (pcdc->GetSafeHdc(), rect.left, rect.top, rect.right, rect.bottom); SelectObject(pcdc->GetSafeHdc(), hOldBrush); DeleteObject (hNewBrush); } void CZoomViewOptionsDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) { RepaintButton(IDBTN_ZOOMVIEW_SRCCOLOR, m_pZoomView->crSrcBorder); RepaintButton(IDBTN_ZOOMVIEW_DSTCOLOR, m_pZoomView->crZoomViewBorder); RepaintButton(IDBTN_ZOOMVIEW_CALLOUTCOLOR, m_pZoomView->crCallout); CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct); } void CZoomViewOptionsDlg::OnZoomviewCalloutcolor() { m_pZoomView->crCallout= ShowColorDlg (m_pZoomView->crCallout); RepaintButton(IDBTN_ZOOMVIEW_CALLOUTCOLOR, m_pZoomView->crCallout); } void CZoomViewOptionsDlg::OnKillfocusZoomFactor() { ValidateZoomFactor(m_pZoomView->nZoom); } CZoomViewOptionsDlg::ValidateZoomFactor(int nOldValue) { int nValue; nValue = (int)GetDlgItemInt(IDEDT_ZOOMVIEW_ZOOMFACTOR, NULL, FALSE); if(nValue < 100) { nValue = nOldValue; SetDlgItemInt(IDEDT_ZOOMVIEW_ZOOMFACTOR, nOldValue, FALSE); return nValue; } else if(nValue > 800) { nValue = nOldValue; SetDlgItemInt(IDEDT_ZOOMVIEW_ZOOMFACTOR, nOldValue, FALSE); return nValue; } return nValue; } void CZoomViewOptionsDlg::InitDstCombo() { GetDlgItem(IDCMB_ZOOMVIEW_DSTBORDERSTYLE)->EnableWindow(TRUE); GetDlgItem(IDCMB_ZOOMVIEW_DSTAPPEARANCE)->EnableWindow(TRUE); GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(TRUE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); switch (GetCurSelValue(IDCMB_ZOOMVIEW_DSTSHAPE)) { case ZOOMVIEWBORDERSTYLE_TEAROUT: GetDlgItem(IDCMB_ZOOMVIEW_DSTBORDERSTYLE)->EnableWindow(FALSE); GetDlgItem(IDCMB_ZOOMVIEW_DSTAPPEARANCE)->EnableWindow(FALSE); GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(FALSE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); break; case ZOOMVIEWBORDERSTYLE_ROUNDED: GetDlgItem(IDCMB_ZOOMVIEW_DSTAPPEARANCE)->EnableWindow(FALSE); if(GetCurSelValue(IDCMB_ZOOMVIEW_DSTBORDERSTYLE) == ZOOMVIEWBORDERSTYLE_NONE) { GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(FALSE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); } else { GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(TRUE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); } break; case 0: if(GetCurSelValue(IDCMB_ZOOMVIEW_DSTAPPEARANCE) == ZOOMVIEWBORDERSTYLE_3D) { GetDlgItem(IDCMB_ZOOMVIEW_DSTBORDERSTYLE)->EnableWindow(FALSE); GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(FALSE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); } else { GetDlgItem(IDCMB_ZOOMVIEW_DSTBORDERSTYLE)->EnableWindow(TRUE); if(GetCurSelValue(IDCMB_ZOOMVIEW_DSTBORDERSTYLE) == ZOOMVIEWBORDERSTYLE_SIMPLE) { GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(TRUE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); } else { GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(FALSE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(FALSE); } } break; default: GetDlgItem(IDCMB_ZOOMVIEW_DSTBORDERSTYLE)->EnableWindow(TRUE); GetDlgItem(IDCMB_ZOOMVIEW_DSTPEN)->EnableWindow(TRUE); GetDlgItem(IDBTN_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); GetDlgItem(IDSTC_ZOOMVIEW_DSTCOLOR)->EnableWindow(TRUE); break; } } void CZoomViewOptionsDlg::OnSelChangeDstAppearance() { InitDstCombo(); } void CZoomViewOptionsDlg::OnSelChangeDstBorderStyle() { InitDstCombo(); } void CZoomViewOptionsDlg::OnSelChangeDstShape() { InitDstCombo(); }