Files
envi-code/SourceCode/Code2026/tg_shs/shs_annotate/CellDialog.cpp
T
2026-09-28 15:28:50 +08:00

323 lines
7.8 KiB
C++

// CellDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CellDialog.h"
#include "charDlg.h"//add by whl
extern TARCH_IMPEXP XString GetSymbolName(AcDbObjectId idSymbolRec);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//TARCH_IMPEXP bool FindRT_MANIFEST();
////////////////////////////////////////////////////////////
CCellDialog::CCellDialog(CWnd* pParent /*=NULL*/)
: CCellPropDlg(CCellDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CCellDialog)
m_csText = _T("");
//}}AFX_DATA_INIT
}
void CCellDialog::DoDataExchange(CDataExchange* pDX)
{
CCellPropDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCellDialog)
DDX_Text(pDX, IDC_TEXT, m_csText);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCellDialog, CCellPropDlg)
//add by whl
ON_COMMAND_RANGE(ID_SPECIAL_CHAR, ID_PICKTEXT, OnChar)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
//{{AFX_MSG_MAP(CCellDialog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCellDialog message handlers
void
CCellDialog::Obj2Dlg(const TDbSheet *pSheet, int nRow, int nCol)
{
CCellPropDlg::Obj2Dlg(pSheet, nRow, nCol);
ASSERT(pSheet);
const TGridCell *pCell=(*pSheet)(nRow, nCol);
m_csText = pCell->GetText();
}
void
CCellDialog::Dlg2Obj(TDbSheet *pSheet, int nRow, int nCol) const
{
CCellPropDlg::Dlg2Obj(pSheet, nRow, nCol);
ASSERT(pSheet);
TGridCell *pCell=(*pSheet)(nRow, nCol);;
pSheet->assertWriteEnabled();
pCell->SetText(m_csText);
}
//Add by whl begin
BOOL CCellDialog::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
// if there is a top level routing frame then let it handle the message
if (GetRoutingFrame() != NULL) return FALSE;
// to be thorough we will need to handle UNICODE versions of the message also !!
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
//TCHAR szFullText[512];
CString strTipText;
// Zyu modify on 100726,支持64位
//UINT nID = pNMHDR->idFrom;
UINT nID = (UINT)pNMHDR->idFrom;
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
{
// idFrom is actually the HWND of the tool
//nID = ::GetDlgCtrlID((HWND)nID);
return FALSE; // shen rui add 对话框控件不显示
}
if (nID != 0) // will be zero on a separator
{
//LoadString(AfxGetResourceHandle(), nID, szFullText, 8);
//strTipText=szFullText;
CTemporaryResourceOverride vTmp;
strTipText.LoadString(nID); //=szFullText;
#ifndef _UNICODE
if (pNMHDR->code == TTN_NEEDTEXTA)
{
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
}
else
{
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
}
#else
if (pNMHDR->code == TTN_NEEDTEXTA)
{
_wcstombsz(pTTTA->szText, strTipText,sizeof(pTTTA->szText));
}
else
{
lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
}
#endif
// bring the tooltip window above other popup windows
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE;
}
return TRUE;
}
BOOL CCellDialog::OnInitDialog()
{
CCellPropDlg::OnInitDialog();
CTemporaryResourceOverride vTmp;
m_toolbar.Create(this);
m_toolbar.LoadToolBar(IDR_TOOLBAR_TEXT);
m_toolbar.ShowWindow(SW_SHOW);
m_toolbar.SetBarStyle(CBRS_ALIGN_TOP | CBRS_TOOLTIPS | CBRS_FLYBY );
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
return TRUE;
}
void CCellDialog::OnChar(UINT nID)
{
UpdateData(TRUE);
int h, l;
if(!GetPosition(h, l))
return;
int i = 0;// Modify By Lcf On 2005-07-01
CEdit *pEdit = (CEdit*)GetDlgItem(IDC_TEXT);
switch (nID)
{
case ID_DOWN_MARK:
if(h==l)
{
AfxMessageBox(_T("请先在文字框中选择字符!"));
return;
}
m_csText.Insert(l, _T("^L"));
m_csText.Insert(h + 2, _T("^L"));
i=h+4;
break;
case ID_UP_MARK:
if(h==l)
{
AfxMessageBox(_T("请先在文字框中选择字符!"));
return;
}
m_csText.Insert(l, _T("^U"));
m_csText.Insert(h + 2,_T("^U"));
i=h+4;
break;
case ID_CIRCLE:
if(h==l)
{
AfxMessageBox(_T("请先在文字框中选择字符!"));
return;
}
m_csText.Insert(l, _T("^C"));
m_csText.Insert(h + 2,_T("^C"));
i=h+4;
break;
case ID_ANGLE_CHAR:
m_csText.Delete(l, h - l);
m_csText.Insert(l, _T("%%d"));
i=l+3;
break;
case ID_DIA_CHAR:
m_csText.Delete(l, h - l);
m_csText.Insert(l, _T("%%c"));
i=l+3;
break;
case ID_TOLERANCE_CHAR:
m_csText.Delete(l, h - l);
m_csText.Insert(l, _T("%%p"));
i=l+3;
break;
case ID_PERCENT_CHAR:
m_csText.Delete(l, h - l);
m_csText.Insert(l, _T("%%%"));
i=l+3;
break;
case ID_ONE_STEEL:
m_csText.Delete(l, h - l);
m_csText.Insert(l,_T("^1"));
i=l+2;
break;
case ID_TWO_STEEL:
m_csText.Delete(l, h - l);
m_csText.Insert(l,_T("^2"));
i=l+2;
break;
case ID_THREE_STEEL:
m_csText.Delete(l, h - l);
m_csText.Insert(l,_T("^3"));
i=l+2;
break;
case ID_FOUR_STEEL:
m_csText.Delete(l, h - l);
m_csText.Insert(l,_T("^4"));
i=l+2;
break;
case ID_SPECIAL_CHAR:
{
CCharDlg dlg(this);
CString str;
CTemporaryResourceOverride vTemp;
if(dlg.DoModal()!= IDOK || dlg.m_character== _T(""))
return;
str = dlg.m_character;
m_csText.Delete(l, h - l);
m_csText.Insert(l,str);
i=l+str.GetLength();
}
break;
case ID_WORD://词库
{
CInsTextDlg dlg(this);
dlg.SetPreText(m_csText);
dlg.SetSingleText(FALSE); // sg add 090324,返回值可支持多行文字
if(dlg.DoModal()!=IDOK||dlg.GetEditText()==_T(""))
return;
m_csText.Delete(l,h-l);
m_csText.Insert(l,dlg.GetEditText());
i=l+dlg.GetEditText().GetLength();;
}
break;
case ID_PICKTEXT:// Add By Lcf On 2005-07-01
{
BeginEditorCommand();
Entity ent;
RBList mask(RTDXF0,_T("TCH_*,TEXT"),NULL);
XPoint pt;
if(SelectEntity(_T("\n屏幕拾取文字内容:"),ent,pt,mask) != RTNORM)
{
CompleteEditorCommand();
return;
}
PickSet ss(SS_FREE);
ss+=ent;
TSubText* pSubText = HitTestOnText(ss,Ucs2Wcs(pt));
if(pSubText!=NULL)
{
CString sText=pSubText->GetText();
delete pSubText;
m_csText.Delete(l,h-l);
m_csText.Insert(l,sText);
i=l+sText.GetLength();;
}
CompleteEditorCommand();
}
break;
}
UpdateData(FALSE);
pEdit->SetSel(i,i);
}
// Modify by lcf On 2005-07-05
BOOL CCellDialog::GetPosition(int& h, int& l)
{
CEdit *pEdit =(CEdit*)GetDlgItem(IDC_TEXT);
DWORD n;
if(pEdit!=GetFocus())
{
int nSel = pEdit->LineLength();
pEdit->SetSel(nSel, nSel);
}
n = pEdit->GetSel();
l = (int)LOWORD(n);
h = (int)HIWORD(n);
#if (ADS>15)
if(!FindRT_MANIFEST())
return TRUE;
OSVERSIONINFO osVer;
osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
VERIFY(GetVersionEx(&osVer)==TRUE);
if(osVer.dwPlatformId==VER_PLATFORM_WIN32_NT && osVer.dwMajorVersion>=5 && osVer.dwMinorVersion>=1) {
CString csText;
pEdit->GetWindowText(csText);
XString xsText;
xsText=csText;
// Zyu modify on 100726,去掉编译警告
//int nCount=_tcslen(xsText);
int nCount = (int)_tcslen(xsText);
int iLow=l, iUp=h;
for(int idx=0; idx<nCount; idx++) {
if(idx>=iUp)
break;
TCHAR c=xsText[idx];
if(c<0) { //汉字
if(idx<iLow)
iLow++;
if(idx<iUp)
iUp++;
idx++;
}
}
l=iLow;
h=iUp;
}
#endif
return TRUE;
}