// SingleRowText.cpp : implementation file // #include "stdafx.h" #include "SingleRowText.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif const int maxHisList = 10; static int g_nAlignIndex = 6; static XExplodeDraw::TextAlignment g_AlignList[] = { XExplodeDraw::kTopLeft, XExplodeDraw::kTopCenter , XExplodeDraw::kTopRight, XExplodeDraw::kMiddleLeft , XExplodeDraw::kMiddleCenter, XExplodeDraw::kMiddleRight , XExplodeDraw::kBottomLeft, XExplodeDraw::kBottomCenter , XExplodeDraw::kBottomRight,}; ///////////////////////////////////////////////////////////////////////////// // CSingleRowText dialog BOOL CSingleRowText::m_bContinue=TRUE;// Add by lcf on 2005-06-30 CString CSingleRowText::m_strHeight = _T("3.5"); CString CSingleRowText::m_strRotation = _T("0"); // add by xly on 101014 记录文字样式变为静态变量,初始化 CString CSingleRowText::m_strFontStyle = _T(""); extern CString DocGetTgSingleTextStyle(); extern BOOL DocSetTgSingleTextStyle(CString &csStyle); IMPLEMENT_DYNAMIC(CSingleRowText, CCharToolbarDlg) CSingleRowText::CSingleRowText(BOOL bEdit, CWnd* pParent /*=NULL*/) : CCharToolbarDlg(CSingleRowText::IDD, pParent),m_bEditObj(bEdit) { m_bChangeCurTextStyle=true; //{{AFX_DATA_INIT(CSingleRowText) m_strInputText = _T(""); m_bTextMask=FALSE; //}}AFX_DATA_INIT // modify by xly on 110310 从图纸中获得文字样式 //// modify by xly on 101014 记录文字样式变为静态变量 ///*TCHAR sStyle[256]=_T(""); //xg_getvar(_T("TEXTSTYLE"), sStyle); //m_strFontStyle=sStyle;*/ //if (m_strFontStyle.IsEmpty()) //{ // TCHAR sStyle[256]=_T(""); // xg_getvar(_T("TEXTSTYLE"), sStyle); // m_strFontStyle = sStyle; //} m_strFontStyle = DocGetTgSingleTextStyle(); // Add By Lcf On 2005-6-06-30 m_bPost = FALSE; m_nOperCode = -1; } void CSingleRowText::DoDataExchange(CDataExchange* pDX) { CCharToolbarDlg::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSingleRowText) DDX_Control(pDX, IDC_COMBO_ALIGNMENT, m_comboAlign); DDX_Control(pDX, IDC_COMBO_HISTORY_TEXT, m_comboHistory); DDX_Control(pDX, IDC_COMBO_FONGSTYLE, m_comboStyleName); if(pDX->m_bSaveAndValidate) { DDX_CBString(pDX, IDC_COMBO_FONGSTYLE, m_strFontStyle); } else { m_comboStyleName.SetCurSel(m_comboStyleName.FindStringExact(0, m_strFontStyle)); } DDX_CBString(pDX, IDC_COMBO_HEIGHT, m_strHeight); if(pDX->m_bSaveAndValidate && _tstof(m_strHeight)<1.0E-3) pDX->Fail(); if(pDX->m_bSaveAndValidate) { DDX_CBString(pDX, IDC_COMBO_HISTORY_TEXT, m_strInputText); } else { GetDlgItem(IDC_COMBO_HISTORY_TEXT)->SetWindowText(m_strInputText); } DDX_Text(pDX, IDC_ROTATION, m_strRotation); DDX_Check(pDX, IDC_TEXTMASK, m_bTextMask); DDX_Check(pDX, IDC_CONTINUE, m_bContinue); //}}AFX_DATA_MAP DDX_CBIndex(pDX, IDC_COMBO_ALIGNMENT, g_nAlignIndex); } BEGIN_MESSAGE_MAP(CSingleRowText, CCharToolbarDlg) //{{AFX_MSG_MAP(CSingleRowText) ON_CBN_SELCHANGE(IDC_COMBO_HISTORY_TEXT, OnSelchangeComboHistoryText) ON_CBN_SELCHANGE(IDC_COMBO_FONGSTYLE, OnSelchangeComboFongstyle) ON_BN_CLICKED(IDC_BUTTON_TEXT_HEIGHT, OnButtonTextHeight) ON_WM_ACTIVATE() ON_WM_CLOSE() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON_ANGLE, OnBnClickedButtonAngle) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSingleRowText message handlers BOOL CSingleRowText::OnInitDialog() { CCharToolbarDlg::OnInitDialog(); LoadTextStyle(); LoadHisText(); m_comboAlign.SetCurSel(g_nAlignIndex); UpdateData(FALSE); if(!m_bEditObj) { if(m_comboHistory.GetCount() == 0) m_strInputText = _T("上华单行文字输入"); if(m_lstHistory.Length()>0) m_strInputText = m_lstHistory[0]; } UpdateData(FALSE); m_ctrlInputText = GetDlgItem(IDC_COMBO_HISTORY_TEXT); m_comboHistory.SetFocus(); // Add By Lcf On 2005-6-06-30 if(!m_bEditObj) { CRect rOk; GetDlgItem(IDOK)->GetWindowRect(rOk); CRect rect; GetWindowRect(rect); rect.bottom -= rOk.Height(); rect.bottom -= 5;//add by whl MoveWindow(rect); GetDlgItem(IDOK)->ShowWindow(SW_HIDE); GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); } else GetDlgItem(IDC_CONTINUE)->ShowWindow(SW_HIDE); return FALSE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } const TCHAR *CSingleRowText::GetHistoryFileName() { return _T("text.his"); } void CSingleRowText::LoadHisText() { TCHAR strTmpPath[100] = _T(""); GetTempPath(100, strTmpPath); _tcscat(strTmpPath, GetHistoryFileName()); #if (ADS>15) std:: #endif ifstream in(strTmpPath); while(!(!in)) { char line[256]; in.getline(line, 255); if(!in) break; m_lstHistory.Append(tstrnew(TString(line))); } for (int m =0; m < m_lstHistory.Length(); m++) m_comboHistory.AddString(m_lstHistory[m]); UpdateData(false); } void CSingleRowText::LoadTextStyle() { // modify by xly on 101015 不将所有的文字样式转化为大写 /* XSymbolList lstStyle(_T("STYLE")); for (int m =0; m < lstStyle.Length(); m++) m_comboStyleName.AddString(lstStyle[m]); */ AcDbDatabase *pCurDwg = acdbCurDwg(); AcDbTextStyleTable* pTT = NULL; VERIFY(pCurDwg->getSymbolTable(pTT, AcDb::kForRead)==Acad::eOk); AcDbTextStyleTableIterator* pIter = NULL; VERIFY(pTT->newIterator(pIter)==Acad::eOk); pTT->close(); for (pIter->start(); !pIter->done(); pIter->step()) { AcDbTextStyleTableRecord* pTTR; if (pIter->getRecord(pTTR, AcDb::kForRead) != Acad::eOk) continue; const TCHAR* pName = NULL; if (pTTR->getName(pName) == Acad::eOk && pName != NULL) { if (m_lstStyle.Index(pName) < 0 ) // 如果没有重复 m_lstStyle.Append(tstrnew(pName)); // 读字体风格 } pTTR->close(); } delete pIter; // add by xly on 110311 从图纸中读取文字样式 // sg modify 110818,如果是对象编辑,不能修改文字样式,只在布置单行文字的时候,才需要处理 if(!m_bEditObj) { m_strFontStyle = DocGetTgSingleTextStyle(); } // add by xly on 110106 如果使用新创建的文字样式,图纸切换时产生bug // 标记文字样式中,是否有当前样式 bool bIsHas(false); for (int m =0; m < m_lstStyle.Length(); m++) { m_comboStyleName.AddString(m_lstStyle[m]); // 标记文字样式中有当前样式 if (m_lstStyle[m] == m_strFontStyle) { bIsHas = true; } } // 没有当前样式,设置默认样式Stantard if (!bIsHas) { TCHAR sStyle[256]=_T(""); xg_getvar(_T("TEXTSTYLE"), sStyle); m_strFontStyle = sStyle; } //UpdateData(false); // add by xly on 110429 文字样式不存在 if (m_strFontStyle.IsEmpty()) { TCHAR sStyle[256]=_T(""); xg_getvar(_T("TEXTSTYLE"), sStyle); m_strFontStyle = sStyle; } } void CSingleRowText::Obj2Dlg(TDbText *pText) { m_bTextMask=(pText->GetMaskFlag()!=0); m_strHeight.Format(_T("%.1f"), pText->GetHeight()); m_strRotation = (const TCHAR *)Angle2Str(Wcs2Ucs(pText->GetRotation()) * 180.0 / PI); AcDbObjectId idTextStyle = pText->GetStyleId(); OPENOBJ_BEGIN(idTextStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle); ASSERT(pStyle); const TCHAR* pName = NULL; if (pStyle->getName(pName) == Acad::eOk && pName != NULL) m_strFontStyle = pName; else AfxMessageBox(_T("文字样式已删除!")); OPENOBJ_END(); m_strInputText = pText->GetText(); XExplodeDraw::TextAlignment Align = pText->GetAlignment(); for(int i = 0; i < 9; i++) { if(Align == g_AlignList[i]) g_nAlignIndex = i; } } void CSingleRowText::Dlg2Obj(TDbText *pText) { //XString sTextStyle = m_strStyle; //xg_setvar(_T("TEXTSTYLE"), sTextStyle); AcDbObjectId idTextStyle = GetTextStyleId(m_strFontStyle); if(!idTextStyle) return; pText->SetStyleId(idTextStyle); //g_nHeight = _tstof(m_strHeight); pText->SetHeight(_tstof(m_strHeight)); pText->SetRotation(Ucs2Wcs(_tstof(m_strRotation) * PI / 180.0)); pText->SetText(m_strInputText); pText->SetAlignment(g_AlignList[g_nAlignIndex]); pText->SetMaskFlag(m_bTextMask); } void CSingleRowText::OnOK() { AddToRecent(); CCharToolbarDlg::OnOK(); if(!m_bEditObj&&m_bChangeCurTextStyle) // ZJQ modify on 2004/3/5 xg_setvar(_T("TEXTSTYLE"), m_strFontStyle); } void CSingleRowText::AddToRecent() { { UpdateData(TRUE); int len = m_lstHistory.Length(); //g_nAlignIndex = m_comboAlign.GetCurSel(); //if(g_nAlignIndex < 0) // g_nAlignIndex = 6; TCHAR strTmpPath[256] = _T(""); GetTempPath(255, strTmpPath); _tcscat(strTmpPath, GetHistoryFileName()); #if (ADS>15) std:: #endif ofstream out(strTmpPath); if(m_strInputText != _T("")) { out << (const char *)_AS(m_strInputText) << "\n"; int index = m_lstHistory.Index(m_strInputText); if(index >= 0) { m_lstHistory.Remove(index); len --; } if(len > maxHisList-1) len = maxHisList - 1; } for(int i=0; i < len; i++) out << _AS(m_lstHistory[i]) <<"\n"; } m_lstHistory.Reset(); m_comboHistory.ResetContent(); LoadHisText(); } void CSingleRowText::OnSelchangeComboHistoryText() { if(m_comboHistory.GetCurSel()>=0) m_comboHistory.GetLBText(m_comboHistory.GetCurSel(), m_strInputText); } void CSingleRowText::OnSelchangeComboFongstyle() { UpdateData(TRUE); AcDbObjectId idTextStyle = GetTextStyleId(m_strFontStyle); if(!idTextStyle) return; // add by xly on 110310保存文字样式到图纸中 DocSetTgSingleTextStyle(m_strFontStyle); UpdateData(FALSE); } void CSingleRowText::OnCancel() { CCharToolbarDlg::OnCancel(); } // Modify By Lcf On 2005-6-06-30 void CSingleRowText::OnButtonTextHeight() { if(!m_bEditObj && m_bPost) { m_nOperCode = 0; PostCommand(_T("` "), false); } else { GetTextHeight(); acedGetAcadDwgView()->SetFocus(); } } // Add By Lcf On 2005-6-06-30 void CSingleRowText::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { CCharToolbarDlg::OnActivate(nState, pWndOther, bMinimized); if(nState == WA_CLICKACTIVE) { int nSel = m_comboHistory.GetWindowTextLength(); m_comboHistory.SetEditSel(nSel, nSel); } else if(nState == WA_INACTIVE) { UpdateData(); if(!m_bEditObj && m_bPost) PostCommand(_T("` "), false); } } // Add By Lcf On 2005-6-06-30 void CSingleRowText::OnClose() { if(!m_bEditObj) { m_bPost = FALSE; PostCommand(_T(" "), false); } CCharToolbarDlg::OnClose(); } // Add By Lcf On 2005-6-06-30 void CSingleRowText::GetTextHeight() { XPushAutoHide noAutoHide(this); XPushMemVar vTemp(m_bPost,FALSE); m_nOperCode = -1; UpdateData(TRUE); double nHeight = _tstof(m_strHeight)*DocGetPScale(); BeginEditorCommand(); if(GetDist(_T("\n字高"), nHeight, RSG_NOZERO|RSG_NONEG) == RTNORM) { nHeight /= DocGetPScale(); m_strHeight.Format(_T("%.1f"), nHeight); } CompleteEditorCommand(); UpdateData(FALSE); } // Add By Lcf On 20050808 void CSingleRowText::OnBnClickedButtonAngle() { if(m_bModeless && m_bPost) { m_nOperCode = 2; PostCommand(_T("` "), false); } else { GetTextAngle(); acedGetAcadDwgView()->SetFocus(); } } // Add By Lcf On 2005-6-06-30 void CSingleRowText::GetTextAngle() { XPushAutoHide noAutoHide(this); XPushMemVar vTemp(m_bPost,FALSE); m_nOperCode = -1; UpdateData(TRUE); double nAngle = 0.0; BeginEditorCommand(); if(acedGetAngle(NULL, _T("\n文字转角<") + m_strRotation + _T(">:"), &nAngle) == RTNORM) m_strRotation.Format(_T("%lf"), nAngle*180/PI); CompleteEditorCommand(); UpdateData(FALSE); } //////////////////////////////////////////////////////////////////////////// // CDrawingNameDlg int CDrawingNameDlg::m_nStyle=1; // sg modify 120706,9.0起不再使用当前样式,而是使用记忆上一次的样式 //CString CDrawingNameDlg::m_strFontStyle1=_T("STANDARD"); //CString CDrawingNameDlg::m_strFontStyle2=_T("STANDARD"); CString CDrawingNameDlg::m_strFontStyle1 = GetTextStyleName(TS_DRAWINGNAME); CString CDrawingNameDlg::m_strFontStyle2 = GetTextStyleName(TS_DRAWINGNAME); CString CDrawingNameDlg::m_strHeight2=_T("5.0"); CString CDrawingNameDlg::m_strHeight1=_T("7.0"); CString CDrawingNameDlg::m_csScaleText=_T(""); BOOL CDrawingNameDlg::m_bNoScale=FALSE; BOOL CDrawingNameDlg::m_bContinue=TRUE; IMPLEMENT_DYNAMIC(CDrawingNameDlg,CCharToolbarDlg) CDrawingNameDlg::CDrawingNameDlg(BOOL bEdit, CWnd* pParent /*=NULL*/) : CCharToolbarDlg(bEdit?CDrawingNameDlg::IDD1:CDrawingNameDlg::IDD, pParent) , mPreviewDb(true,true) , bPreviewReady(false) { m_bChangeCurTextStyle=false; TCHAR sStyle[256] = _T(""); // sg delete 120706,9.0起不再使用当前样式,而是使用记忆上一次的样式 //xg_getvar(_T("TEXTSTYLE"), sStyle); //m_strFontStyle1 = sStyle; //m_strFontStyle2 = sStyle; if(m_csScaleText == _T("")) { double bScale = DocGetPScale(); if(fabs(bScale - 1.0) < 1e-6) m_csScaleText.Format(_T("1:%.0f"), 1000 * bScale); else m_csScaleText.Format(_T("1:%.0f"), bScale); } AcDbRegAppTable *pTab = NULL; VERIFY(mPreviewDb.getSymbolTable(pTab, AcDb::kForWrite)==Acad::eOk); if(!pTab->has(TCHXD)) { AcDbRegAppTableRecord *pRec=new AcDbRegAppTableRecord(); pRec->setName(TCHXD); pTab->add(pRec); pRec->close(); } pTab->close(); // Add By Lcf On 2005-6-06-30 m_bPost = FALSE; m_nOperCode = -1; m_nHeightType = 1; } void CDrawingNameDlg::UpdatePreview() { if(m_bModeless)//add by whl on 060213 return; mPreviewCtrl.clearAll(); mPreviewCtrl.init(true); { AcDbBlockTable *pBlockTab=NULL; if(mPreviewDb.getSymbolTable(pBlockTab, AcDb::kForWrite)!=Acad::eOk) return; AcDbBlockTableRecord*pMspace=new AcDbBlockTableRecord; pMspace->setName(_T("*U")); AcDbObjectId blockId; pBlockTab->add(blockId,pMspace); pBlockTab->close(); AcGePoint3d target; double length,width; Draw(pMspace,target,length,width); AcGePoint3d position(target.x,target.y,1); mPreviewCtrl.view()->setView(position, target,AcGeVector3d(0.0, 1.0, 0.0),length,width); mPreviewCtrl.view()->add(pMspace,mPreviewCtrl.model()); pMspace->close(); } mPreviewCtrl.Invalidate(); } BOOL CDrawingNameDlg::DestroyWindow() { mPreviewCtrl.clearAll(); return CCharToolbarDlg::DestroyWindow(); } void CDrawingNameDlg::Draw(AcDbBlockTableRecord*pSpace,AcGePoint3d¢er,double&length,double &width) { TDbDrawingName *pDrawingName = new TDbDrawingName; Dlg2Obj(pDrawingName); pDrawingName->SetRotation(0.0); pDrawingName->setLayer(pDrawingName->GetDefaultLayer()); // pDrawingName->SetLocation(AcGePoint3d(0, 0, 0)); pDrawingName->SetMidLocation(AcGePoint3d(0, 0, 0)); pDrawingName->SetPScale(1); //modify by xlc on 091019 解决2010平台编辑时对象不显示的问题 #if ADS<18 pSpace->appendAcDbEntity(pDrawingName); XPoint ptMin,ptMax; pDrawingName->GetExtents2d(ptMin, ptMax); pDrawingName->close(); #else XPoint ptMin,ptMax; pDrawingName->GetExtents2d(ptMin, ptMax); AcDbEntity *pClone=(AcDbEntity*)pDrawingName->clone(); delete pDrawingName; pClone->setDatabaseDefaults(&mPreviewDb); pSpace->appendAcDbEntity(pClone); pClone->recordGraphicsModified(); pClone->close(); #endif center.x=(ptMin.x+ptMax.x)/2; center.y=(ptMin.y+ptMax.y)/2; length=(ptMax.x-ptMin.x)*1.2; width=(ptMax.y-ptMin.y)*1.2; if(length>2.5*width) width=length/2.5; else length=width*2.5; } void CDrawingNameDlg::DoDataExchange(CDataExchange* pDX) { CCharToolbarDlg::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDrawingNameDlg) DDX_Control(pDX, IDC_COMBO_FONGSTYLE1, m_comboStyleName1); DDX_Control(pDX, IDC_COMBO_FONGSTYLE2, m_comboStyleName2); if(pDX->m_bSaveAndValidate) { DDX_CBString(pDX, IDC_NAME_LIST, m_strInputText); DDX_CBString(pDX, IDC_SCALE_LIST, m_csScaleText); DDX_CBString(pDX, IDC_COMBO_FONGSTYLE1, m_strFontStyle1); DDX_CBString(pDX, IDC_COMBO_FONGSTYLE2, m_strFontStyle2); } else { GetDlgItem(IDC_NAME_LIST)->SetWindowText(m_strInputText); GetDlgItem(IDC_SCALE_LIST)->SetWindowText(m_csScaleText); //m_comboStyleName1.SetCurSel(m_comboStyleName1.FindStringExact(0, m_strFontStyle1)); //m_comboStyleName2.SetCurSel(m_comboStyleName2.FindStringExact(0, m_strFontStyle2)); } DDX_CBString(pDX, IDC_COMBO_HEIGHT1, m_strHeight1); DDX_CBString(pDX, IDC_COMBO_HEIGHT2, m_strHeight2); if(pDX->m_bSaveAndValidate && _tstof(m_strHeight1)<1.0E-3) pDX->Fail(); if(pDX->m_bSaveAndValidate && _tstof(m_strHeight2)<1.0E-3) pDX->Fail(); DDX_Check(pDX, IDC_NO_SCALE, m_bNoScale); DDX_Radio(pDX, IDC_STYLE1, m_nStyle); DDX_Control(pDX, IDC_NAME_LIST, m_comboName); DDX_Control(pDX, IDC_SCALE_LIST, m_comboScale); DDX_Check(pDX, IDC_CONTINUE, m_bContinue); //}}AFX_DATA_MAP if(bPreviewReady) UpdatePreview(); } BEGIN_MESSAGE_MAP(CDrawingNameDlg, CCharToolbarDlg) //{{AFX_MSG_MAP(CDrawingNameDlg) ON_BN_CLICKED(IDC_STYLE1, OnBnClickedUpdate) ON_BN_CLICKED(IDC_STYLE2, OnBnClickedUpdate) ON_CBN_SELCHANGE(IDC_COMBO_FONGSTYLE1, OnBnClickedUpdate) ON_CBN_SELCHANGE(IDC_COMBO_FONGSTYLE2, OnBnClickedUpdate) ON_BN_CLICKED(IDC_NO_SCALE, OnBnClickedNoScale) ON_CBN_SELCHANGE(IDC_COMBO_HEIGHT1, OnCbnSelchangeComboHeight1) ON_CBN_SELCHANGE(IDC_COMBO_HEIGHT2, OnCbnSelchangeComboHeight2) ON_BN_CLICKED(IDC_BUTTON_TEXT_HEIGHT1, OnButtonTextHeight1) ON_BN_CLICKED(IDC_BUTTON_TEXT_HEIGHT2, OnButtonTextHeight2) ON_CBN_SELCHANGE(IDC_NAME_LIST, OnCbnSelchangeNameList) ON_CBN_SELCHANGE(IDC_SCALE_LIST, OnCbnSelchangeScaleList) ON_WM_ACTIVATE() ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDrawingNameDlg message handlers const TCHAR * CDrawingNameDlg::GetHistoryFileName() { return _T("drawingname.his"); } void CDrawingNameDlg::LoadHisText() { TCHAR strTmpPath[100] = _T(""); GetTempPath(100, strTmpPath); _tcscat(strTmpPath, GetHistoryFileName()); #if (ADS>15) std:: #endif ifstream in(strTmpPath); while(!(!in)) { char line[256]; in.getline(line, 255); if(!in) break; m_lstHistory.Append(tstrnew(TString(line))); } for (int m =0; m < m_lstHistory.Length(); m++) m_comboName.AddString(m_lstHistory[m]); UpdateData(false); } void CDrawingNameDlg::LoadTextStyle() { XSymbolList lstStyle(_T("STYLE")); for (int m =0; m < lstStyle.Length(); m++) { m_comboStyleName1.AddString(lstStyle[m]); m_comboStyleName2.AddString(lstStyle[m]); } } BOOL CDrawingNameDlg::OnInitDialog() { CCharToolbarDlg::OnInitDialog(); if (!mPreviewCtrl.SubclassDlgItem(IDC_PREVIEW,this)) return FALSE; LoadTextStyle(); LoadHisText(); // sg modify 120706,增加一个判断,如果当前记忆的样式没有的话,那么使用上华固定的文字样式 int nRet = m_comboStyleName1.FindStringExact(0, m_strFontStyle1); if (nRet < 0) { nRet = m_comboStyleName1.FindStringExact(0, _T("STANDARD")); } m_comboStyleName1.SetCurSel(nRet); nRet = m_comboStyleName2.FindStringExact(0, m_strFontStyle2); if (nRet < 0) { nRet = m_comboStyleName2.FindStringExact(0, _T("STANDARD")); } m_comboStyleName2.SetCurSel(nRet); bPreviewReady=true; m_ctrlInputText = GetDlgItem(IDC_NAME_LIST); GetDlgItem(IDC_SCALE_LIST)->SetWindowText(m_csScaleText); if(m_bModeless) { if(m_comboName.GetCount() == 0) m_strInputText = _T("上华图名标注输入"); if(m_lstHistory.Length()>0) m_strInputText = m_lstHistory[0]; } UpdateData(FALSE); m_comboName.SetFocus(); GetDlgItem(IDC_SCALE_LIST)->EnableWindow(!m_bNoScale); GetDlgItem(IDC_BUTTON_TEXT_HEIGHT2)->EnableWindow(!m_bNoScale); GetDlgItem(IDC_COMBO_FONGSTYLE2)->EnableWindow(!m_bNoScale); GetDlgItem(IDC_COMBO_HEIGHT2)->EnableWindow(!m_bNoScale); // Add By Lcf On 2005-6-06-30 if(m_bModeless) { GetDlgItem(IDOK)->ShowWindow(SW_HIDE); GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); } else GetDlgItem(IDC_CONTINUE)->ShowWindow(SW_HIDE); return TRUE; } void CDrawingNameDlg::OnBnClickedUpdate() { UpdateData(); } void CDrawingNameDlg::OnButtonTextHeight2() { m_nHeightType = 2; if(m_bModeless && m_bPost) { m_nOperCode = 0; PostCommand(_T("` "), false); } else { GetTextHeight(); acedGetAcadDwgView()->SetFocus(); } } void CDrawingNameDlg::OnButtonTextHeight1() { m_nHeightType = 1; if(m_bModeless && m_bPost) { m_nOperCode = 0; PostCommand(_T("` "), false); } else { GetTextHeight(); acedGetAcadDwgView()->SetFocus(); } } void CDrawingNameDlg::OnCbnSelchangeComboHeight1() { CComboBox*pBox=((CComboBox*)GetDlgItem(IDC_COMBO_HEIGHT1)); if(pBox->GetCurSel()>=0) pBox->GetLBText(pBox->GetCurSel(),m_strHeight1); pBox->SetWindowText(m_strHeight1); UpdateData(); } void CDrawingNameDlg::OnCbnSelchangeComboHeight2() { CComboBox*pBox=((CComboBox*)GetDlgItem(IDC_COMBO_HEIGHT2)); if(pBox->GetCurSel()>=0) pBox->GetLBText(pBox->GetCurSel(),m_strHeight2); pBox->SetWindowText(m_strHeight2); UpdateData(); } void CDrawingNameDlg::OnBnClickedNoScale() { UpdateData(); GetDlgItem(IDC_SCALE_LIST)->EnableWindow(!m_bNoScale); GetDlgItem(IDC_BUTTON_TEXT_HEIGHT2)->EnableWindow(!m_bNoScale); GetDlgItem(IDC_COMBO_FONGSTYLE2)->EnableWindow(!m_bNoScale); GetDlgItem(IDC_COMBO_HEIGHT2)->EnableWindow(!m_bNoScale); } void CDrawingNameDlg::OnCbnSelchangeScaleList() { if(m_comboScale.GetCurSel()>=0) m_comboScale.GetLBText(m_comboScale.GetCurSel(),m_csScaleText); m_comboScale.SetWindowText(m_csScaleText); UpdateData(); } void CDrawingNameDlg::OnCbnSelchangeNameList() { CComboBox*pBox=((CComboBox*)GetDlgItem(IDC_NAME_LIST)); if(pBox->GetCurSel()>=0) pBox->GetLBText(pBox->GetCurSel(),m_strInputText); pBox->SetWindowText(m_strInputText); UpdateData(); } void CDrawingNameDlg::OnOK() { AddToRecent(); CCharToolbarDlg::OnOK(); if(m_bModeless&&m_bChangeCurTextStyle) // ZJQ modify on 2004/3/5 xg_setvar(_T("TEXTSTYLE"), m_strFontStyle1); } void CDrawingNameDlg::AddToRecent() { { UpdateData(TRUE); int len = m_lstHistory.Length(); TCHAR strTmpPath[256] = _T(""); GetTempPath(255, strTmpPath); _tcscat(strTmpPath, GetHistoryFileName()); #if (ADS>15) std:: #endif ofstream out(strTmpPath); if(m_strInputText != _T("")) { out << (const char *)_AS(m_strInputText) << "\n"; int index = m_lstHistory.Index(m_strInputText); if(index >= 0) { m_lstHistory.Remove(index); len --; } if(len > maxHisList-1) len = maxHisList - 1; } for(int i=0; i < len; i++) out << _AS(m_lstHistory[i]) << "\n"; } m_lstHistory.Reset(); m_comboName.ResetContent(); LoadHisText(); } // Add by lcf 2004/12/01 void CDrawingNameDlg::Dlg2Obj(TDbDrawingName* pDrawingName) { AcDbObjectId idTextStyle1 = GetTextStyleId(m_strFontStyle1); if(!idTextStyle1) return; pDrawingName->SetNameText(m_strInputText); pDrawingName->SetNameStyleId(idTextStyle1); pDrawingName->SetNameHeight(_tstof(m_strHeight1)); AcDbObjectId idTextStyle2 = GetTextStyleId(m_strFontStyle2); if(!idTextStyle2) return; pDrawingName->SetScaleText(m_csScaleText); pDrawingName->SetScaleStyleId(idTextStyle2); pDrawingName->SetScaleHeight(_tstof(m_strHeight2)); pDrawingName->SetShowScale(!m_bNoScale); pDrawingName->SetDrawStyle(m_nStyle); } void CDrawingNameDlg::Obj2Dlg(TDbDrawingName* pDrawingName) { if(pDrawingName == NULL) return; m_strInputText = pDrawingName->GetNameText(); m_csScaleText = pDrawingName->GetScaleText(); m_strFontStyle1 = GetSymbolName(pDrawingName->GetNameStyleId()); m_strFontStyle2 = GetSymbolName(pDrawingName->GetScaleStyleId()); m_strHeight1.Format(_T("%.1f"), pDrawingName->GetNameHeight()); m_strHeight2.Format(_T("%.1f"), pDrawingName->GetScaleHeight()); m_bNoScale = !pDrawingName->GetShowScale(); m_nStyle = pDrawingName->GetDrawStyle(); } // Add By Lcf On 2005-6-06-30 void CDrawingNameDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) { CCharToolbarDlg::OnActivate(nState, pWndOther, bMinimized); if(!m_bModeless)//add by whl on 060213 return; if(nState == WA_CLICKACTIVE) { int nSel = m_comboName.GetWindowTextLength(); m_comboName.SetEditSel(nSel, nSel); } else if(nState == WA_INACTIVE) { UpdateData(); if(m_bModeless&& m_bPost) PostCommand(_T("` "), false); } } // Add By Lcf On 2005-6-06-30 void CDrawingNameDlg::OnClose() { if(m_bModeless) { m_bPost = FALSE; PostCommand(_T(" "), false); } CCharToolbarDlg::OnClose(); } // Add By Lcf On 2005-6-06-30 void CDrawingNameDlg::GetTextHeight() { XPushAutoHide noAutoHide(this); XPushMemVar vTemp(m_bPost,FALSE); m_nOperCode = -1; UpdateData(TRUE); double nHeight; if(m_nHeightType == 1) nHeight = _tstof(m_strHeight1)*DocGetPScale(); else nHeight = _tstof(m_strHeight2)*DocGetPScale(); BeginEditorCommand(); if(GetDist(_T("\n字高"), nHeight, RSG_NOZERO|RSG_NONEG) == RTNORM) { nHeight /= DocGetPScale(); if(m_nHeightType == 1) m_strHeight1.Format(_T("%.1f"), nHeight); else m_strHeight2.Format(_T("%.1f"), nHeight); } CompleteEditorCommand(); UpdateData(FALSE); }