// TextSettingDlg.cpp : implementation file // #include "stdafx.h" //#include #include "TextSettingDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif int CALLBACK EnumFontFamExProc3(ENUMLOGFONTEX *lplf, NEWTEXTMETRICEX *lpntme, int FontType, LONG lParam) { if (!(FontType & TRUETYPE_FONTTYPE)) return 1 ; if (*(lplf->elfLogFont.lfFaceName)) { if(!_tcsicmp(lplf->elfLogFont.lfFaceName, _T("marlett"))) return 1; if(g_lstWinfont.Index(lplf->elfLogFont.lfFaceName, 0) < 0 && _tcsicmp((const TCHAR*)lplf->elfScript, _T("CHINESE_GB2312")) == 0) {// winFont g_lstWinfont.Append(tstrnew(lplf->elfLogFont.lfFaceName)); g_lstCharset.Append(new int(lplf->elfLogFont.lfCharSet)); g_lstPitch.Append(new int(lplf->elfLogFont.lfPitchAndFamily)); } } return 1 ; } ///////////////////////////////////////////////////////////////////////////// // CTextSettingDlg dialog CTextSettingDlg::CTextSettingDlg(CWnd* pParent /*=NULL*/) : CDialog(CTextSettingDlg::IDD, pParent) { //{{AFX_DATA_INIT(CTextSettingDlg) m_csPipeDnStyle = g_csPipeDnStyle; m_csVPipeStyle = g_csVPipeStyle; m_csPipeTextStyle = g_csPipeTextStyle; m_csCircleTextStyle = g_csCircleTextStyle; m_csDimWellStyle = g_csDimWellStyle; m_csSheetStyle = g_csSheetStyle; m_csDimStyle = g_csTwtDimStyle; m_bWin1 = FALSE; m_bWin2 = FALSE; m_bWin3 = FALSE; m_bWin4 = FALSE; m_bWin5 = FALSE; m_bWin6 = FALSE; m_bWin7 = FALSE; m_iChn1 = -1; m_iChn2 = -1; m_iChn3 = -1; m_iChn4 = -1; m_iChn5 = -1; m_iChn6 = -1; m_iChn7 = -1; m_iEng1 = -1; m_iEng2 = -1; m_iEng3 = -1; m_iEng4 = -1; m_iEng5 = -1; m_iEng6 = -1; m_iEng7 = -1; m_nHeight1 = g_nPipeDnHeight; m_nHeight2 = g_nVPipeHeight; m_nHeight3 = g_nPipeTextHeight; m_nHeight4 = g_nCircleTextHeight; m_nHeight5 = g_nDimWellHeight; m_nHeight6 = g_nSheetHeight; m_nHeight7 = g_nTwtDimHeight; m_nScale1 = g_nPipeDnScale; m_nScale2 = g_nVPipeScale; m_nScale3 = g_nPipeTextScale; m_nScale4 = g_nCircleTextScale; m_nScale5 = g_nDimWellScale; m_nScale6 = g_nSheetScale; m_nScale7 = g_nDimScale; m_nScale8 = g_dLineTypeScale; m_nHeight8 = g_dLineTypeHeight; m_iEng8 = -1; m_iChn8 = -1; m_bWin8 = FALSE; m_csTextLineStyle = g_csLineTypeStyle; m_bWin9 = FALSE; m_iChn9 = -1; m_iEng9 = -1; m_nHeight9 = g_nSanTextHeight; // cet 2010.12.16 add m_nScale9 = g_nSanTextScale; // cet 2010.12.16 add m_csSanTextStyle = g_csSanTextStyle; // cet 2010.12.16 add m_bWin10 = FALSE; m_iChn10 = -1; m_iEng10 = -1; m_nHeight10 = g_nEleDimHeight;// zxl 2012.07.02 add m_nScale10 = g_nEleDimScale;// zxl 2012.07.02 add m_csPipeElevStyle = g_csEleDimStyle;// zxl 2012.07.02 add //}}AFX_DATA_INIT } void CTextSettingDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTextSettingDlg) DDX_Control(pDX, IDC_COMBO_ENG10, m_comboEng10); DDX_Control(pDX, IDC_COMBO_CHN10, m_comboChn10); DDX_Control(pDX, IDC_COMBO_ENG9, m_comboEng9); DDX_Control(pDX, IDC_COMBO_CHN9, m_comboChn9); DDX_Control(pDX, IDC_COMBO_CHN8, m_comboChn8); DDX_Control(pDX, IDC_COMBO_ENG8, m_comboEng8); DDX_Control(pDX, IDC_COMBO_ENG7, m_comboEng7); DDX_Control(pDX, IDC_COMBO_ENG6, m_comboEng6); DDX_Control(pDX, IDC_COMBO_ENG5, m_comboEng5); DDX_Control(pDX, IDC_COMBO_ENG4, m_comboEng4); DDX_Control(pDX, IDC_COMBO_ENG3, m_comboEng3); DDX_Control(pDX, IDC_COMBO_ENG2, m_comboEng2); DDX_Control(pDX, IDC_COMBO_ENG1, m_comboEng1); DDX_Control(pDX, IDC_COMBO_CHN7, m_comboChn7); DDX_Control(pDX, IDC_COMBO_CHN6, m_comboChn6); DDX_Control(pDX, IDC_COMBO_CHN5, m_comboChn5); DDX_Control(pDX, IDC_COMBO_CHN4, m_comboChn4); DDX_Control(pDX, IDC_COMBO_CHN3, m_comboChn3); DDX_Control(pDX, IDC_COMBO_CHN2, m_comboChn2); DDX_Control(pDX, IDC_COMBO_CHN1, m_comboChn1); DDX_Text(pDX, IDC_EDIT_STYLE1, m_csPipeDnStyle); DDX_Text(pDX, IDC_EDIT_STYLE2, m_csVPipeStyle); DDX_Text(pDX, IDC_EDIT_STYLE3, m_csPipeTextStyle); DDX_Text(pDX, IDC_EDIT_STYLE4, m_csCircleTextStyle); DDX_Text(pDX, IDC_EDIT_STYLE5, m_csDimWellStyle); DDX_Text(pDX, IDC_EDIT_STYLE6, m_csSheetStyle); DDX_Text(pDX, IDC_EDIT_STYLE7, m_csDimStyle); DDX_Check(pDX, IDC_CHECK_WIN1, m_bWin1); DDX_Check(pDX, IDC_CHECK_WIN2, m_bWin2); DDX_Check(pDX, IDC_CHECK_WIN3, m_bWin3); DDX_Check(pDX, IDC_CHECK_WIN4, m_bWin4); DDX_Check(pDX, IDC_CHECK_WIN5, m_bWin5); DDX_Check(pDX, IDC_CHECK_WIN6, m_bWin6); DDX_Check(pDX, IDC_CHECK_WIN7, m_bWin7); DDX_CBIndex(pDX, IDC_COMBO_CHN1, m_iChn1); DDX_CBIndex(pDX, IDC_COMBO_CHN2, m_iChn2); DDX_CBIndex(pDX, IDC_COMBO_CHN3, m_iChn3); DDX_CBIndex(pDX, IDC_COMBO_CHN4, m_iChn4); DDX_CBIndex(pDX, IDC_COMBO_CHN5, m_iChn5); DDX_CBIndex(pDX, IDC_COMBO_CHN6, m_iChn6); DDX_CBIndex(pDX, IDC_COMBO_CHN7, m_iChn7); DDX_CBIndex(pDX, IDC_COMBO_ENG1, m_iEng1); DDX_CBIndex(pDX, IDC_COMBO_ENG2, m_iEng2); DDX_CBIndex(pDX, IDC_COMBO_ENG3, m_iEng3); DDX_CBIndex(pDX, IDC_COMBO_ENG4, m_iEng4); DDX_CBIndex(pDX, IDC_COMBO_ENG5, m_iEng5); DDX_CBIndex(pDX, IDC_COMBO_ENG6, m_iEng6); DDX_CBIndex(pDX, IDC_COMBO_ENG7, m_iEng7); DDX_Text(pDX, IDC_EDIT_HEIGHT1, m_nHeight1); DDX_Text(pDX, IDC_EDIT_HEIGHT2, m_nHeight2); DDX_Text(pDX, IDC_EDIT_HEIGHT3, m_nHeight3); DDX_Text(pDX, IDC_EDIT_HEIGHT4, m_nHeight4); DDX_Text(pDX, IDC_EDIT_HEIGHT5, m_nHeight5); DDX_Text(pDX, IDC_EDIT_HEIGHT6, m_nHeight6); DDX_Text(pDX, IDC_EDIT_HEIGHT7, m_nHeight7); DDX_Text(pDX, IDC_EDIT_SCALE1, m_nScale1); DDX_Text(pDX, IDC_EDIT_SCALE2, m_nScale2); DDX_Text(pDX, IDC_EDIT_SCALE3, m_nScale3); DDX_Text(pDX, IDC_EDIT_SCALE4, m_nScale4); DDX_Text(pDX, IDC_EDIT_SCALE5, m_nScale5); DDX_Text(pDX, IDC_EDIT_SCALE6, m_nScale6); DDX_Text(pDX, IDC_EDIT_SCALE7, m_nScale7); DDX_Text(pDX, IDC_EDIT_SCALE8, m_nScale8); DDX_Text(pDX, IDC_EDIT_HEIGHT8, m_nHeight8); DDX_CBIndex(pDX, IDC_COMBO_ENG8, m_iEng8); DDX_CBIndex(pDX, IDC_COMBO_CHN8, m_iChn8); DDX_Check(pDX, IDC_CHECK_WIN8, m_bWin8); DDX_Text(pDX, IDC_EDIT_STYLE8, m_csTextLineStyle); DDX_Check(pDX, IDC_CHECK_WIN9, m_bWin9); DDX_CBIndex(pDX, IDC_COMBO_CHN9, m_iChn9); DDX_CBIndex(pDX, IDC_COMBO_ENG9, m_iEng9); DDX_Text(pDX, IDC_EDIT_HEIGHT9, m_nHeight9); DDX_Text(pDX, IDC_EDIT_SCALE9, m_nScale9); DDX_Text(pDX, IDC_EDIT_STYLE9, m_csSanTextStyle); DDX_Check(pDX, IDC_CHECK_WIN10, m_bWin10); DDX_CBIndex(pDX, IDC_COMBO_CHN10, m_iChn10); DDX_CBIndex(pDX, IDC_COMBO_ENG10, m_iEng10); DDX_Text(pDX, IDC_EDIT_HEIGHT10, m_nHeight10); DDX_Text(pDX, IDC_EDIT_SCALE10, m_nScale10); DDX_Text(pDX, IDC_EDIT_STYLE10, m_csPipeElevStyle); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CTextSettingDlg, CDialog) //{{AFX_MSG_MAP(CTextSettingDlg) ON_BN_CLICKED(IDC_CHECK_WIN1, OnCheckWin1) ON_BN_CLICKED(IDC_CHECK_WIN2, OnCheckWin2) ON_BN_CLICKED(IDC_CHECK_WIN3, OnCheckWin3) ON_BN_CLICKED(IDC_CHECK_WIN4, OnCheckWin4) ON_BN_CLICKED(IDC_CHECK_WIN5, OnCheckWin5) ON_BN_CLICKED(IDC_CHECK_WIN6, OnCheckWin6) ON_BN_CLICKED(IDC_CHECK_WIN7, OnCheckWin7) ON_BN_CLICKED(IDC_CHECK_WIN8, OnCheckWin8) ON_BN_CLICKED(IDC_CHECK_WIN9, OnCheckWin9) ON_BN_CLICKED(IDC_CHECK_WIN10, OnCheckWin10) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTextSettingDlg message handlers BOOL CTextSettingDlg::OnInitDialog() { CDialog::OnInitDialog(); LoadFontList(); for(int i=0;im_hDC, &lf, (FONTENUMPROC)EnumFontFamExProc3, NULL, 0); m_comboEng7.ReleaseDC(pDC); m_lstChnShx.Reset(); m_lstEngShx.Reset(); XStringList lstSearchPath; GetSearchPath(lstSearchPath); for(int i=0; iEnableWindow(FALSE); else pWnd1->EnableWindow(TRUE); if(m_bWin2) pWnd2->EnableWindow(FALSE); else pWnd2->EnableWindow(TRUE); if(m_bWin3) pWnd3->EnableWindow(FALSE); else pWnd3->EnableWindow(TRUE); if(m_bWin4) pWnd4->EnableWindow(FALSE); else pWnd4->EnableWindow(TRUE); if(m_bWin5) pWnd5->EnableWindow(FALSE); else pWnd5->EnableWindow(TRUE); if(m_bWin6) pWnd6->EnableWindow(FALSE); else pWnd6->EnableWindow(TRUE); if(m_bWin7) pWnd7->EnableWindow(FALSE); else pWnd7->EnableWindow(TRUE); if(m_bWin8) pWnd8->EnableWindow(FALSE); else pWnd8->EnableWindow(TRUE); // cet 2010.12.16 add if(m_bWin9) pWnd9->EnableWindow(FALSE); else pWnd9->EnableWindow(TRUE); // zxl 2012.07.02 add if(m_bWin10) pWnd10->EnableWindow(FALSE); else pWnd10->EnableWindow(TRUE); } void CTextSettingDlg::UpdateTextStyle(const TCHAR* szSyle, const TCHAR* szChn, const TCHAR* szEng, double nHeight, double nScale) { AcDbObjectId id = GetTextStyleId(szSyle); OPENOBJ_BEGIN(id, AcDb::kForWrite, AcDbTextStyleTableRecord, pRec); if(pRec){ int idx = g_lstWinfont.Index(szChn); if(idx < 0){ pRec->setFileName(szEng); pRec->setBigFontFileName(szChn); } else { int iCharset = *g_lstCharset[idx]; int iPitch = *g_lstPitch[idx]; #if ADS < 21 pRec->setFont(szChn, FALSE, FALSE, iCharset, iPitch); #else typedef Autodesk::AutoCAD::PAL::FontUtils::FontPitch FontPitch; typedef Autodesk::AutoCAD::PAL::FontUtils::FontFamily FontFamily; pRec->setFont(szChn, Adesk::kFalse, Adesk::kFalse, (Charset)iCharset, (FontPitch)(iPitch&0x3), (FontFamily)(iPitch&0xF0)); #endif } pRec->setXScale(nScale); pRec->setTextSize(nHeight); } OPENOBJ_END(); } void CTextSettingDlg::OnOK() { Save(); g_lstWinfont.Reset(); g_lstCharset.Reset(); g_lstPitch.Reset(); CDC *pDC = acedGetAcadDwgView()->GetDC(); ASSERT(pDC); LOGFONT lf; ZeroMemory(&lf,sizeof(lf)); lf.lfCharSet = DEFAULT_CHARSET; EnumFontFamiliesEx(pDC->m_hDC, &lf, (FONTENUMPROC)EnumFontFamExProc3, NULL, 0); acedGetAcadDwgView()->ReleaseDC(pDC); XSymbolList lstStyle(_T("STYLE")); if(lstStyle.Index(g_csPipeDnStyle) > -1) UpdateTextStyle(g_csPipeDnStyle, g_csPipeDnChn, g_csPipeDnEng, g_nPipeDnHeight, g_nPipeDnScale); if(lstStyle.Index(g_csVPipeStyle) > -1) UpdateTextStyle(g_csVPipeStyle, g_csVPipeChn, g_csVPipeEng, g_nVPipeHeight, g_nVPipeScale); if(lstStyle.Index(g_csPipeTextStyle) > -1) UpdateTextStyle(g_csPipeTextStyle, g_csPipeTextChn, g_csPipeTextEng, g_nPipeTextHeight, g_nPipeTextScale); if(lstStyle.Index(g_csCircleTextStyle) > -1) UpdateTextStyle(g_csCircleTextStyle, g_csCircleTextChn, g_csCircleTextEng, g_nCircleTextHeight, g_nCircleTextScale); if(lstStyle.Index(g_csDimWellStyle) > -1) UpdateTextStyle(g_csDimWellStyle, g_csDimWellChn, g_csDimWellEng, g_nDimWellHeight, g_nDimWellScale); if(lstStyle.Index(g_csSheetStyle) > -1) UpdateTextStyle(g_csSheetStyle, g_csSheetChn, g_csSheetEng, g_nSheetHeight, g_nSheetScale); if(lstStyle.Index(g_csTwtDimStyle) > -1) UpdateTextStyle(g_csTwtDimStyle, g_csDimChn, g_csDimEng, g_nTwtDimHeight, g_nDimScale); if(lstStyle.Index(g_csLineTypeStyle) > -1) UpdateTextStyle(g_csLineTypeStyle, g_csLineTypeChnShx, g_csLineTypeEngShx, g_dLineTypeHeight, g_dLineTypeScale); // zxl 2012.07.03 add if (lstStyle.Index(g_csEleDimStyle) > -1) { UpdateTextStyle(g_csEleDimStyle, g_csEleDimChn, g_csEleDimEng, g_nEleDimHeight, g_nEleDimScale); } // cet 2014.2.24 add 实时更新 if (lstStyle.Index(g_csSanTextStyle) > -1) { UpdateTextStyle(g_csSanTextStyle, g_csSanTextChn, g_csSanTextEng, g_nSanTextHeight, g_nSanTextScale); } CDialog::OnOK(); } void CTextSettingDlg::Save() { UpdateData(TRUE); g_nPipeDnHeight = m_nHeight1; g_nPipeDnScale = m_nScale1; g_nVPipeHeight = m_nHeight2; g_nVPipeScale = m_nScale2; g_nPipeTextHeight = m_nHeight3; g_nPipeTextScale = m_nScale3; g_nCircleTextHeight = m_nHeight4; g_nCircleTextScale = m_nScale4; g_nDimWellHeight = m_nHeight5; g_nDimWellScale = m_nScale5; g_nSheetHeight = m_nHeight6; g_nSheetScale = m_nScale6; g_nTwtDimHeight = m_nHeight7; g_nDimScale = m_nScale7; g_dLineTypeScale = m_nScale8; g_dLineTypeHeight = m_nHeight8; g_nSanTextScale = m_nScale9; // cet 2010.12.16 add g_nSanTextHeight = m_nHeight9; // cet 2010.12.16 add g_nEleDimHeight = m_nHeight10; // zxl 2012.07.02 add g_nEleDimScale = m_nScale10; // zxl 2012.07.02 add if(m_iChn1 > -1) m_comboChn1.GetLBText(m_iChn1, g_csPipeDnChn); if(m_iChn2 > -1) m_comboChn2.GetLBText(m_iChn2, g_csVPipeChn); if(m_iChn3 > -1) m_comboChn3.GetLBText(m_iChn3, g_csPipeTextChn); if(m_iChn4 > -1) m_comboChn4.GetLBText(m_iChn4, g_csCircleTextChn); if(m_iChn5 > -1) m_comboChn5.GetLBText(m_iChn5, g_csDimWellChn); if(m_iChn6 > -1) m_comboChn6.GetLBText(m_iChn6, g_csSheetChn); if(m_iChn7 > -1) m_comboChn7.GetLBText(m_iChn7, g_csDimChn); if(m_iChn8 > -1) m_comboChn8.GetLBText(m_iChn8, g_csLineTypeChnShx); if (m_iChn9 > -1) // cet 2010.12.16 add m_comboChn9.GetLBText(m_iChn9, g_csSanTextChn); if(m_iChn10 > -1) // zxl 2012.07.02 add m_comboChn10.GetLBText(m_iChn10, g_csEleDimChn); if(m_iEng1 > -1) m_comboEng1.GetLBText(m_iEng1, g_csPipeDnEng); if(m_iEng2 > -1) m_comboEng2.GetLBText(m_iEng2, g_csVPipeEng); if(m_iEng3 > -1) m_comboEng3.GetLBText(m_iEng3, g_csPipeTextEng); if(m_iEng4 > -1) m_comboEng4.GetLBText(m_iEng4, g_csCircleTextEng); if(m_iEng5 > -1) m_comboEng5.GetLBText(m_iEng5, g_csDimWellEng); if(m_iEng6 > -1) m_comboEng6.GetLBText(m_iEng6, g_csSheetEng); if(m_iEng7 > -1) m_comboEng7.GetLBText(m_iEng7, g_csDimEng); if(m_iEng8 > -1) m_comboEng8.GetLBText(m_iEng8, g_csLineTypeEngShx); if(m_iEng9 > -1) // cet 2010.12.16 add m_comboEng9.GetLBText(m_iEng9, g_csSanTextEng); if(m_iEng10 > -1)// zxl 2012.07.02 add m_comboEng10.GetLBText(m_iEng10, g_csEleDimEng); CRegProperty regProp(GetRegLocation(), _T("TWTConfig")); regProp.SetTopRootKey(HKEY_CURRENT_USER); regProp.SetValue(_T("LineTypeChnShx"), g_csLineTypeChnShx); regProp.SetValue(_T("LineTypeEngShx"), g_csLineTypeEngShx); regProp.SetValue(_T("LineTypeHeight"), g_dLineTypeHeight); regProp.SetValue(_T("LineTypeScale"), g_dLineTypeScale); regProp.SetValue(_T("PipeDnChn"), g_csPipeDnChn); regProp.SetValue(_T("VPipeChn"), g_csVPipeChn); regProp.SetValue(_T("PipeTextChn"), g_csPipeTextChn); regProp.SetValue(_T("CircleTextChn"), g_csCircleTextChn); regProp.SetValue(_T("DimWellChn"), g_csDimWellChn); regProp.SetValue(_T("SheetChn"), g_csSheetChn); regProp.SetValue(_T("DimChn"), g_csDimChn); regProp.SetValue(_T("SanTextChn"), g_csSanTextChn); // cet 2010.12.16 add regProp.SetValue(_T("EleDimChn"), g_csEleDimChn); // zxl 2012.07.02 add regProp.SetValue(_T("PipeDnEng"), g_csPipeDnEng); regProp.SetValue(_T("VPipeEng"), g_csVPipeEng); regProp.SetValue(_T("PipeTextEng"), g_csPipeTextEng); regProp.SetValue(_T("CircleTextEng"), g_csCircleTextEng); regProp.SetValue(_T("DimWellEng"), g_csDimWellEng); regProp.SetValue(_T("SheetEng"), g_csSheetEng); regProp.SetValue(_T("DimEng"), g_csDimEng); regProp.SetValue(_T("SanTextEng"), g_csSanTextEng); // cet 2010.12.16 add regProp.SetValue(_T("EleDimEng"), g_csEleDimEng); // zxl 2012.07.02 add regProp.SetValue(_T("PipeDnHeight"), g_nPipeDnHeight); regProp.SetValue(_T("VPipeHeight"), g_nVPipeHeight); regProp.SetValue(_T("PipeTextHeight"), g_nPipeTextHeight); regProp.SetValue(_T("CircleTextHeight"), g_nCircleTextHeight); regProp.SetValue(_T("DimWellHeight"), g_nDimWellHeight); regProp.SetValue(_T("SheetHeight"), g_nSheetHeight); regProp.SetValue(_T("DimHeight"), g_nTwtDimHeight); regProp.SetValue(_T("SanTextHeight"), g_nSanTextHeight); // cet 2010.12.16 add regProp.SetValue(_T("EleDimHeight"), g_nEleDimHeight); // zxl 2012.07.02 add regProp.SetValue(_T("PipeDnScale"), g_nPipeDnScale); regProp.SetValue(_T("VPipeScale"), g_nVPipeScale); regProp.SetValue(_T("PipeTextScale"), g_nPipeTextScale); regProp.SetValue(_T("CircleTextScale"), g_nCircleTextScale); regProp.SetValue(_T("DimWellScale"), g_nDimWellScale); regProp.SetValue(_T("SheetScale"), g_nSheetScale); regProp.SetValue(_T("DimScale"), g_nDimScale); regProp.SetValue(_T("SanTextScale"), g_nSanTextScale); // cet 2010.12.16 add regProp.SetValue(_T("EleDimScale"), g_nEleDimScale); // zxl 2012.07.02 add }