#include "stdafx.h" #include "resource.h" #include "GridStyleDialog.h" ///////////////////////////////////////////////////////////////////////////// // CGridStyleDialog dialog const TCHAR * g_szHorModes[5]={_T("继承"), _T("左对齐"), _T("居中"), _T("右对齐"), _T("两端对齐"),}; const TCHAR * g_szVerModes[4]={_T("继承"), _T("靠上"), _T("居中"), _T("靠下"), }; const TCHAR * g_szFactors[]={_T("继承"), _T("0"), _T("0.1"), _T("0.2"), _T("0.3"), _T("0.4"), _T("0.5"), _T("0.6"), _T("0.7"), _T("0.8"), _T("0.9"), _T("1.0")}; const TCHAR * g_szTextSizes[]={_T("继承"), _T("2.5"), _T("3.0"), _T("3.5"), _T("4.0"), _T("5.0"), _T("7.0"), _T("10.0"), _T("14.0"), _T("20.0"), }; int g_nHorModeNum=ELEMENTS(g_szHorModes); int g_nVerModeNum=ELEMENTS(g_szVerModes); int g_nFactorNum=ELEMENTS(g_szFactors); int g_nTextSizeNum=ELEMENTS(g_szTextSizes); AcDb::TextHorzMode Index2HorMode(int nIndex) { AcDb::TextHorzMode nHorMode; switch(nIndex) { case 1: nHorMode=AcDb::kTextLeft; break; case 2: nHorMode=AcDb::kTextCenter; break; case 3: nHorMode=AcDb::kTextRight; break; case 4: nHorMode=AcDb::kTextFit; break; default: ASSERT(0); } return nHorMode; } AcDb::TextVertMode Index2VerMode(int nIndex) { AcDb::TextVertMode nVerMode; switch(nIndex) { case 1: nVerMode=AcDb::kTextTop; break; case 2: nVerMode=AcDb::kTextVertMid; break; case 3: nVerMode=AcDb::kTextBottom; break; default: ASSERT(0); } return nVerMode; } int HorMode2Index(AcDb::TextHorzMode nHorMode) { int nIndex=0; switch(nHorMode) { case AcDb::kTextLeft: nIndex=1; break; case AcDb::kTextCenter: case AcDb::kTextMid: nIndex=2; break; case AcDb::kTextRight: nIndex=3; break; case AcDb::kTextFit: nIndex=4; break; default: break; } return nIndex; } int VerMode2Index(AcDb::TextVertMode nVerMode) { int nIndex=0; switch(nVerMode) { case AcDb::kTextTop: nIndex=1; break; case AcDb::kTextVertMid: nIndex=2; break; case AcDb::kTextBase: case AcDb::kTextBottom: nIndex=3; break; default: break; } return nIndex; } CGridStyleDialog::CGridStyleDialog(UINT id, CWnd* pParent /*=NULL*/) : CAcUiDialog(id, pParent) { //{{AFX_DATA_INIT(CGridStyleDialog) m_nHorMode = -1; m_csLineSpaceFactor = _T(""); m_csTextSize = _T(""); m_nTextStyle = -1; m_bTextWrap = FALSE; m_nVerMode = -1; m_bInheritWrapText = FALSE; //}}AFX_DATA_INIT m_nTextColor=0; m_bParentTextWrap=FALSE; for(int i=0; i<5; i++) m_lstHorModes.Append(new XString(g_szHorModes[i])); for(i=0; i<4; i++) m_lstVerModes.Append(new XString(g_szVerModes[i])); for(i=0; im_bSaveAndValidate) { if(_tstof(m_csTextSize)<1.0E-3 || _tstof(m_csLineSpaceFactor)<-1.0E-3) pDX->Fail(); } } BEGIN_MESSAGE_MAP(CGridStyleDialog, CAcUiDialog) //{{AFX_MSG_MAP(CGridStyleDialog) ON_BN_CLICKED(IDC_INHERIT_TEXTWRAP, OnInheritTextwrap) //}}AFX_MSG_MAP END_MESSAGE_MAP() //初始化组合框 void CGridStyleDialog::InitComBox(CComboBox& combox, const DList &lstString) { combox.ResetContent(); for (int i = 0 ; i < lstString.Length(); i++) { combox.AddString(lstString[i]); } } BOOL CGridStyleDialog::OnInitDialog() { CAcUiDialog::OnInitDialog(); InitComBox(m_textSizeBox, m_lstTextSizes); InitComBox(m_horModeBox, m_lstHorModes); InitComBox(m_verModeBox, m_lstVerModes); InitComBox(m_textStyleBox, m_lstTextStyles); InitComBox(m_factorBox, m_lstFactors); GetDlgItem(IDC_TEXTWRAP)->EnableWindow(!m_bInheritWrapText); int nItem=m_colorComboBox.FindItemByColorIndex(m_nTextColor); if(nItem<0) { m_colorComboBox.AddColorToMRU(m_nTextColor); nItem=m_colorComboBox.FindItemByColorIndex(m_nTextColor); } if(nItem>=0) m_colorComboBox.SetCurSel(nItem); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CGridStyleDialog::OnInheritTextwrap() { // TODO: Add your control notification handler code here UpdateData(TRUE); GetDlgItem(IDC_TEXTWRAP)->EnableWindow(!m_bInheritWrapText); if(m_bInheritWrapText) m_bTextWrap=m_bParentTextWrap; UpdateData(FALSE); } void CGridStyleDialog::OnOK() { // 检查对话框输入是否合法 //... int nIndex=m_colorComboBox.GetCurrentItemColorIndex(); if(nIndex>=0) m_nTextColor=nIndex; CAcUiDialog::OnOK(); }