// ArrowTextDlg.cpp : implementation file // #include "stdafx.h" #include "ArrowTextDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CArrowTextDlg dialog const int maxHisList = 10; extern double g_nHeight; static int g_nArrowAlign = 0; static TDbSymbArrow::TArTextAlign g_ArrowAlign[] = {TDbSymbArrow::kAtSide, TDbSymbArrow::kAlignMid, TDbSymbArrow::kAlignEnd}; extern int TARCH_IMPEXP g_nSymbArrowStyle; BOOL CArrowTextDlg::m_bContinue = TRUE; // Add by lcf on 2005-06-29 CString CArrowTextDlg::g_csArrowSize = _T("3.0"); // sg add 090123 CString CArrowTextDlg::m_csText = _T(""); CString CArrowTextDlg::m_csText2 = _T(""); IMPLEMENT_DYNAMIC(CArrowTextDlg, CBaseTextDlg) CArrowTextDlg::CArrowTextDlg(CWnd* pParent /*=NULL*/) : CBaseTextDlg(CArrowTextDlg::IDD, pParent) { //{{AFX_DATA_INIT(CArrowTextDlg) //}}AFX_DATA_INIT } void CArrowTextDlg::DoDataExchange(CDataExchange* pDX) { CBaseTextDlg::DoDataExchange(pDX); //{{AFX_DATA_MAP(CArrowTextDlg) // DDX_CBString(pDX, IDC_COMBO_HISTORY_TEXT, m_strInputText); // sg modify 090225 // sg modify 090507,仿照图名标注,试着解决“对象编辑中,有时候文字显示有问题”的BUG if (pDX->m_bSaveAndValidate) { DDX_CBString(pDX, IDC_COMBO_HISTORY_TEXT, m_csText); DDX_CBString(pDX, IDC_COMBO_TEXT2, m_csText2); } else { GetDlgItem(IDC_COMBO_HISTORY_TEXT)->SetWindowText(m_csText); GetDlgItem(IDC_COMBO_TEXT2)->SetWindowText(m_csText2); } DDX_Control(pDX, IDC_COMBO_HISTORY_TEXT, m_comboHistory); DDX_CBString(pDX, IDC_ARROW_SIZE, g_csArrowSize); if (pDX->m_bSaveAndValidate && _tstof(g_csArrowSize)<1.0E-3) pDX->Fail(); DDX_Check(pDX, IDC_CONTINUE, m_bContinue); DDX_CBIndex(pDX, IDC_COMBO_ALIGNMENT, g_nArrowAlign); DDX_CBIndex(pDX, IDC_ARROW_STYLE, g_nSymbArrowStyle); // Add by lcf on 20050809 DDX_Control(pDX, IDC_COMBO_TEXT2, m_comboText2); // sg add 090108,增加线下文字 //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CArrowTextDlg, CBaseTextDlg) //{{AFX_MSG_MAP(CArrowTextDlg) ON_CBN_SELCHANGE(IDC_COMBO_HISTORY_TEXT, OnSelchangeComboHistoryText) // sg add 090108 ON_CBN_SELCHANGE(IDC_COMBO_TEXT2, OnSelchangeComboText2) ON_CBN_SELCHANGE(IDC_COMBO_ALIGNMENT, OnSelchangeComboAlignment) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CArrowTextDlg message handlers BOOL CArrowTextDlg::OnInitDialog() { CBaseTextDlg::OnInitDialog(); LoadHisText(); UpdateData(FALSE); if (m_bModeless) // sg add 090507,仿照图名标注修改 { if (m_comboHistory.GetCount() == 0) m_csText = _T("上"); // m_strInputText = _T("上"); // sg modify 090225 // else if (m_strInputText==_T("")) // sg modify 090123,林工提出需求,有时候会希望这里不填内容 // m_comboHistory.SetCurSel(0); if (m_comboText2.GetCount() == 0) m_csText2 = _T("下"); // else if (m_csText2==_T("") && m_bModeless && bEnable) // sg delete 090123 // m_comboText2.SetCurSel(0); } // sg add 090108,在线端,只能显示一行文字 BOOL bEnable = g_ArrowAlign[g_nArrowAlign]!=TDbSymbArrow::kAtSide; GetDlgItem(IDC_COMBO_TEXT2)->EnableWindow(bEnable); SetDlgItemText(IDC_ARROW_SIZE, g_csArrowSize); m_comboHistory.SetFocus(); UpdateData(FALSE); return FALSE; // return TRUE unless you set the focus to a control } void CArrowTextDlg::LoadHisText() { TCHAR strTmpPath[100] = _T(""); GetTempPath(100, strTmpPath); _tcscat(strTmpPath, _T("arrow.his")); #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]); m_comboText2.AddString(m_lstHistory[m]); // sg add 090108 } UpdateData(false); } void CArrowTextDlg::Obj2Dlg(TDbSymbArrow *pText) { CBaseTextDlg::Obj2Dlg(pText); // m_strInputText = pText->GetText(); m_csText = pText->GetText(); // sg add 090225 TDbSymbArrow::TArTextAlign Align = pText->GetTextAlign(); for (int i = 0; i < 3; i++) { if (Align == g_ArrowAlign[i]) g_nArrowAlign = i; } g_csArrowSize.Format(_T("%.1f"), pText->GetArrowSize()); g_nSymbArrowStyle = (int)pText->GetArrowType(); m_csText2 = pText->GetText2(); // sg add 090108 } void CArrowTextDlg::Dlg2Obj(TDbSymbArrow *pText) { CBaseTextDlg::Dlg2Obj(pText); // pText->SetText(m_strInputText); // sg modify 090225 pText->SetText(m_csText); pText->SetTextAlign(g_ArrowAlign[g_nArrowAlign]); pText->SetTextLocation(pText->GetDefaultTextLocation()); pText->SetText2Location(pText->GetDefaultText2Location()); // sg add 090107 pText->SetText2(m_csText2); // sg add 090108 BOOL bShowText2 = !m_csText2.IsEmpty(); pText->SetShowText2(bShowText2); double nSize = _tstof(g_csArrowSize); if (nSize > 1.0E-3) pText->SetArrowSize(nSize); pText->SetArrowType((TDbSymbArrow::TArrowType)g_nSymbArrowStyle); } void CArrowTextDlg::OnOK() { AddToRecent(); CBaseTextDlg::OnOK(); } // Add by lcf on 20050708 void CArrowTextDlg::AddToRecent() { { UpdateData(TRUE); int len = m_lstHistory.Length(); TCHAR strTmpPath[256] = _T(""); GetTempPath(255, strTmpPath); _tcscat(strTmpPath, _T("arrow.his")); #if (ADS>15) std:: #endif ofstream out(strTmpPath); // if (m_strInputText != _T("")) // sg add 090225 if (m_csText != _T("")) { // out << (const char *)_AS(m_strInputText) << "\n"; // int index = m_lstHistory.Index(m_strInputText); out << (const char *)_AS(m_csText) << "\n"; // sg add 090225 int index = m_lstHistory.Index(m_csText); if (index >= 0) { m_lstHistory.Remove(index); len --; } if (len > maxHisList-1) len = maxHisList - 1; } // if (m_csText2!=_T("") && _tcscmp(m_csText2, m_strInputText)!=0) // sg add 090108 if (m_csText2!=_T("") && _tcscmp(m_csText2, m_csText)!=0) // sg modify 090225 { out << (const char *)_AS(m_csText2) << "\n"; int nIndex = m_lstHistory.Index(m_csText2); if (nIndex >= 0) { m_lstHistory.Remove(nIndex); 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(); m_comboText2.ResetContent(); // sg add 090108 LoadHisText(); } void CArrowTextDlg::OnSelchangeComboHistoryText() { // if (m_comboHistory.GetCurSel()>=0) // m_comboHistory.GetLBText(m_comboHistory.GetCurSel(), m_csText); // sg modify 090507,仿照图名标注,进行修改 CComboBox *pBox = (CComboBox*)GetDlgItem(IDC_COMBO_HISTORY_TEXT); int nIndex = pBox->GetCurSel(); if (nIndex >= 0) pBox->GetLBText(nIndex, m_csText); pBox->SetWindowText(m_csText); UpdateData(); } // sg add 090108,sg modify 090507,仿照图名标注,进行修改 void CArrowTextDlg::OnSelchangeComboText2() { CComboBox *pBox = (CComboBox*)GetDlgItem(IDC_COMBO_TEXT2); int nIndex = pBox->GetCurSel(); if (nIndex >= 0) pBox->GetLBText(nIndex, m_csText2); pBox->SetWindowText(m_csText2); UpdateData(); } void CArrowTextDlg::OnSelchangeComboAlignment() { UpdateData(TRUE); BOOL bEnable = g_ArrowAlign[g_nArrowAlign]!=TDbSymbArrow::kAtSide; GetDlgItem(IDC_COMBO_TEXT2)->EnableWindow(bEnable); UpdateData(FALSE); } CWnd* CArrowTextDlg::GetCurWnd() { // CWnd *pWnd = GetDlgItem(IDC_COMBO_HISTORY_TEXT); // 把CWnd 回传给基类 // return (pWnd); UpdateData(TRUE); // sg modify 090225 CWnd *pWnd = this->GetFocus(); CWnd *pWnd2 = NULL; if (m_comboHistory.m_hWnd == pWnd->GetParent()->m_hWnd) { pWnd2 = GetDlgItem(IDC_COMBO_HISTORY_TEXT); // 把CWnd 回传给基类 m_strInputText = m_csText; } else if (m_comboText2.m_hWnd == pWnd->GetParent()->m_hWnd) { pWnd2 = GetDlgItem(IDC_COMBO_TEXT2); // 把CWnd 回传给基类 m_strInputText = m_csText2; } else { int nSel = m_comboHistory.GetWindowTextLength(); m_comboHistory.SetEditSel(nSel, nSel); pWnd2 = GetDlgItem(IDC_COMBO_HISTORY_TEXT); } return(pWnd2); } // sg add 090225 void CArrowTextDlg::UpdateInputText() { CWnd *pWnd = this->GetFocus(); if (m_comboHistory.m_hWnd == pWnd->GetParent()->m_hWnd) m_csText = m_strInputText; if (m_comboText2.m_hWnd == pWnd->GetParent()->m_hWnd) m_csText2 = m_strInputText; UpdateData(FALSE); }