📄 rcimeview.cpp
字号:
int yunlen;
//int nYunMu[35];
WCHAR yunmu[8];
int tempi;
WCHAR pch,lch;
// BOOL test;
CString str=_T("");
keynum=1;
//for(i=0;i<35;i++)
// nYunMuIndex[i]=0;
m_selectedsheng=m_selected-2;
//yunsum=sydbmanip.GetAllCombinationYunMu(m_selectedsheng,nYunMuIndex,35);
//yunsum=combination[m_selectedsheng][0];
//for(i=1;i<=yunsum;i++)
// nYunMuIndex[i-1]=combination[m_selectedsheng][i];
m_showstrsum=yunsum;
CRect myrc;
GetClientRect(&myrc);
int hspan=(myrc.right-myrc.left )/9-2;
for(i=1;i<=m_showstrsum;i++)
{
wid=0;
//yunlen=sydbmanip.GetYunMuDescByInx(nYunMuIndex[i-1],yunmu,8);
//yunlen=yunmudesc[nYunMuIndex[i-1]-1][0];
yunlen=yunmudesc[(i-1)*YUNMULEN+0];
for(tempi=1;tempi<8;tempi++)
yunmu[tempi-1]=yunmudesc[(i-1)*YUNMULEN+tempi];
// yunmu[tempi-1]=yunmudesc[nYunMuIndex[i-1]-1][tempi];
for(j=0;j<yunlen;j++)
str.Insert(j+4,yunmu[j]);
//pDC->SetTextColor(m_clrstr);
//if((hspan/2-m_lf.lfWidth*str.GetLength())>0)
// wid=(hspan/2-m_lf.lfWidth*str.GetLength())/2;
// test=pDC->TextOut(textoutpoint[i-1].x+wid,textoutpoint[i-1].y,str);
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
if((hspan-wid)>0)
wid=(hspan-wid)/2;
else wid=0;
pDC->SetTextColor(m_clrBand[(i-1)%9]);
TextOut(pDC, CPoint(textoutpoint[i-1].x+wid,textoutpoint[i-1].y),str);
str.Empty();
/*
pDC->SetTextColor(m_clrnum);
wid=0;
if((keynum % 10)==0) keynum++;
lch=( (keynum) % 10)+0x30;
switch((keynum++)/10)
{
case 0:
pch=' ';break;
case 1:
pch='0';break;
case 2:
pch='+';
};
str.Insert(100,pch);
str.Insert(100,lch);
//((hspan/2-m_lf.lfWidth*str.GetLength())>0)
//wid=(hspan/2-m_lf.lfWidth*str.GetLength())/2;
// test=pDC->TextOut(textoutpoint[i-1].x+wid+hspan/2,textoutpoint[i-1].y,str);
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
TextOut(pDC, CPoint(textoutpoint[i-1].x+1+hspan-wid,textoutpoint[i-1].y),str);
str.Empty();*/
};
}
WORD CRCIMEView::MakeWord(int i,int j)
{
WORD comshengyun;
comshengyun=i*100+j;
return(comshengyun);
}
void CRCIMEView::DrawHanZi(CDC *pDC, CPoint textoutpoint[],WCHAR Buf[],WORD nSum)
{
int i,keynum,wid;
CSize textsize;
int showhanzinum;
BOOL isfirstpage=FALSE,islastpage=FALSE;
WCHAR pch,lch;
// BOOL test;
CString str=_T("");
keynum=1;
if(!m_multipages)
{
showhanzinum=nSum;
isfirstpage=TRUE;
};
if(m_multipages)
{
if (m_PageNo==1) isfirstpage=TRUE;
if((nSum-(m_PageNo-1)*25-1)<=26) islastpage=TRUE;
if(islastpage) showhanzinum=nSum-(m_PageNo-1)*25-1;
else
if(isfirstpage) showhanzinum=26;
else
showhanzinum=25;
};
m_showstrsum=showhanzinum;
CRect myrc;
GetClientRect(&myrc);
int hspan=(myrc.right-myrc.left )/9-2;
for(i=1;i<=showhanzinum;i++)
{
wid=0;
if(isfirstpage) HanZiIntoString(Buf[i-1],str);
else
HanZiIntoString(Buf[(m_PageNo-1)*25+i],str);
//pDC->SetTextColor(m_clrstr);
//if((hspan/2-m_lf.lfWidth*str.GetLength())>0)
// wid=(hspan/2-m_lf.lfWidth*str.GetLength())/2;
// test=pDC->TextOut(textoutpoint[i-1].x+wid,textoutpoint[i-1].y,str);
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
if((hspan-wid)>0)
wid=(hspan-wid)/2;
else wid=0;
pDC->SetTextColor(m_clrBand[(i-1)%9]);
TextOut(pDC, CPoint(textoutpoint[i-1].x+wid,textoutpoint[i-1].y),str);
str.Empty();
/*
pDC->SetTextColor(m_clrnum);
wid=0;
if((keynum % 10)==0) keynum++;
lch=( (keynum) % 10)+0x30;
switch((keynum++)/10)
{
case 0:
pch=' ';break;
case 1:
pch='0';break;
case 2:
pch='+';
};
str.Insert(100,pch);
str.Insert(100,lch);
//if((hspan/2-m_lf.lfWidth*str.GetLength())>0)
// wid=(hspan/2-m_lf.lfWidth*str.GetLength())/2;
// test=pDC->TextOut(textoutpoint[i-1].x+wid+hspan/2,textoutpoint[i-1].y,str);
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
TextOut(pDC, CPoint(textoutpoint[i-1].x+1+hspan-wid,textoutpoint[i-1].y),str);
str.Empty();*/
};
if(m_multipages)
if(m_PageNo==1)
{
//wid=0;
//if((hspan/2-m_lf.lfWidth*4)>0)
// wid=(hspan/2-m_lf.lfWidth*4)/2;
//pDC->SetTextColor(m_clrstr);
// test=pDC->TextOut(textoutpoint[26].x+wid,textoutpoint[26].y,"下页");
str.Empty();
str=_T("下页");
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
if((hspan-wid)>0)
wid=(hspan-wid)/2;
else wid=0;
pDC->SetTextColor(m_clrBand[8]);
TextOut(pDC, CPoint(textoutpoint[26].x+wid,textoutpoint[26].y),str);
/*
wid=0;
//if((hspan/2-m_lf.lfWidth*2)>0)
// wid=(hspan/2-m_lf.lfWidth*2)/2;
pDC->SetTextColor(m_clrnum);
// test=pDC->TextOut(textoutpoint[26].x+wid+hspan/2,textoutpoint[26].y,"+9");
textsize=pDC->GetTextExtent(_T("+9"));
wid=textsize.cx;
TextOut(pDC, CPoint(textoutpoint[26].x+1+hspan-wid,textoutpoint[26].y),_T("+9"));
*/
};
if(m_PageNo!=1)
{
if((nSum-(m_PageNo-1)*25-1)<=26)
{
//wid=0;
//if((hspan/2-m_lf.lfWidth*4)>0)
// wid=(hspan/2-m_lf.lfWidth*4)/2;
//pDC->SetTextColor(m_clrstr);
// test=pDC->TextOut(textoutpoint[26].x+wid,textoutpoint[26].y,"上页");
str.Empty();
str=_T("上页");
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
if((hspan-wid)>0)
wid=(hspan-wid)/2;
else wid=0;
pDC->SetTextColor(m_clrBand[8]);
TextOut(pDC, CPoint(textoutpoint[26].x+wid,textoutpoint[26].y),_T("上页"));
/*
wid=0;
//if((hspan/2-m_lf.lfWidth*2)>0)
// wid=(hspan/2-m_lf.lfWidth*2)/2;
pDC->SetTextColor(m_clrnum);
// test=pDC->TextOut(textoutpoint[26].x+wid+hspan/2,textoutpoint[26].y,"+9");
textsize=pDC->GetTextExtent(_T("+9"));
wid=textsize.cx;
TextOut(pDC, CPoint(textoutpoint[26].x+1+hspan-wid,textoutpoint[26].y),_T("+9"));
*/
};
if(!((nSum-(m_PageNo-1)*25-1)<=26))
{
//wid=0;
//if((hspan/2-m_lf.lfWidth*4)>0)
// wid=(hspan/2-m_lf.lfWidth*4)/2;
//pDC->SetTextColor(m_clrstr);
// test=pDC->TextOut(textoutpoint[25].x+wid,textoutpoint[25].y,"上页");
str.Empty();
str=_T("上页");
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
if((hspan-wid)>0)
wid=(hspan-wid)/2;
else wid=0;
pDC->SetTextColor(m_clrBand[7]);
TextOut(pDC, CPoint(textoutpoint[25].x+wid,textoutpoint[25].y),_T("上页"));
/*
wid=0;
//if((hspan/2-m_lf.lfWidth*2)>0)
// wid=(hspan/2-m_lf.lfWidth*2)/2;
pDC->SetTextColor(m_clrnum);
// test=pDC->TextOut(textoutpoint[25].x+wid+hspan/2,textoutpoint[25].y,"+8");
textsize=pDC->GetTextExtent(_T("+8"));
wid=textsize.cx;
TextOut(pDC, CPoint(textoutpoint[25].x+1+hspan-wid,textoutpoint[25].y),_T("+8"));
*/
//wid=0;
//if((hspan/2-m_lf.lfWidth*4)>0)
// wid=(hspan/2-m_lf.lfWidth*4)/2;
//pDC->SetTextColor(m_clrstr);
// test=pDC->TextOut(textoutpoint[26].x+wid,textoutpoint[26].y,"下页");
str.Empty();
str=_T("下页");
textsize=pDC->GetTextExtent(str);
wid=textsize.cx;
if((hspan-wid)>0)
wid=(hspan-wid)/2;
else wid=0;
pDC->SetTextColor(m_clrBand[8]);
TextOut(pDC, CPoint(textoutpoint[26].x+wid,textoutpoint[26].y),_T("下页"));
/*
wid=0;
//if((hspan/2-m_lf.lfWidth*2)>0)
// wid=(hspan/2-m_lf.lfWidth*2)/2;
pDC->SetTextColor(m_clrnum);
// test=pDC->TextOut(textoutpoint[26].x+wid+hspan/2,textoutpoint[26].y,"+9");
textsize=pDC->GetTextExtent(_T("+9"));
wid=textsize.cx;
TextOut(pDC, CPoint(textoutpoint[26].x+1+hspan-wid,textoutpoint[26].y),_T("+9"));
*/
};
}
}
int CRCIMEView::HanZiIntoString(WCHAR hanzi,CString &str)
{
#ifdef _WIN32_WCE
WCHAR s[2];
s[0] = hanzi;
s[1] = 0;
str = CString(s);
return 1;
#else
int len;
char *temp=new char[2];
len=str.GetLength();
WideCharToMultiByte(CP_ACP,0,&hanzi,1,temp,2,NULL,NULL);
str.Insert(len+1,temp[0]);
str.Insert(len+2,temp[1]);
delete [] temp;
return(1);
#endif
}
/*
void CRCIMEView::DrawBtnDown(int selected)
{
CClientDC* pDC;
int i,j,x,y;
CRect myrc;
GetClientRect(&myrc);
CPen mypen,whitepen,blackpen;
whitepen.CreatePen(PS_SOLID,2,RGB(240,240,240));
blackpen.CreatePen(PS_SOLID,2,RGB(100,100,100));
int hspan=(myrc.right-myrc.left )/9;
int vspan=(myrc.bottom-myrc.top)/3;
j=(selected-1) / 9;
i=(selected-1) % 9;
x=myrc.left+i*hspan;
y=myrc.top +j*vspan;
pDC->SelectObject(&blackpen);
pDC->MoveTo(x+1,y);
pDC->LineTo(x+1,y+vspan);
pDC->MoveTo(x,y+1);
pDC->LineTo(x+hspan,y+1);
pDC->SelectObject(&whitepen);
pDC->MoveTo(x+hspan-1,y+vspan);
pDC->LineTo(x+hspan-1,y+2);
pDC->MoveTo(x+hspan,y+vspan-1);
pDC->LineTo(x+2,y+vspan-1);
}
*/
//DEL void CRCIMEView::GetSYDBFileData(CString filename)
//DEL {
//DEL ///////////////////////////////////////////////////////////
//DEL //open the data file
//DEL /////////////////////////////////////////////////////////
//DEL CFileException e;
//DEL int flag,i,j;
//DEL CFile sydbfile;
//DEL flag=sydbfile.Open(filename,CFile::modeRead,&e);
//DEL if(!flag)
//DEL {
//DEL TRACE(_T("The file can't be opened,the file'name is %s,error=%u\n"),filename,e.m_cause);
//DEL return;
//DEL };
//DEL //////////////////////////////////////////////////////////
//DEL //get shengmu describe string
//DEL //////////////////////////////////////////////////////////
//DEL DWORD pos,shengpos;
//DEL WCHAR ch;
//DEL int sum=0;
//DEL i=0;
//DEL pos=0;
//DEL sydbfile.Seek(16,CFile::begin);
//DEL sydbfile.Read(&shengpos,4);
//DEL for(i=0;i<24;i++)
//DEL {
//DEL sum=1;
//DEL pos=shengpos+i*12;
//DEL sydbfile.Seek(pos,CFile::begin);
//DEL sydbfile.Read(&ch,2);
//DEL while((ch!=0x0000)&&(sum<5))
//DEL {
//DEL m_shengmudesc[i][sum++]=ch;
//DEL sydbfile.Read(&ch,2);
//DEL };
//DEL m_shengmudesc[i][sum]='\0';
//DEL m_shengmudesc[i][0]=sum-1;
//DEL //m_shengmulen[i]=sum;
//DEL };
//DEL /////////////////////////////////////////////////////////////
//DEL //get yunmu describe string
//DEL //////////////////////////////////////////////////////////////
//DEL pos=0;
//DEL DWORD yunpos;
//DEL ch=0;
//DEL sum=0;
//DEL i=0;
//DEL sydbfile.Seek(20,CFile::begin);
//DEL sydbfile.Read(&yunpos,4);
//DEL for(i=0;i<35;i++)
//DEL {
//DEL sum=1;
//DEL pos=yunpos+i*16;
//DEL sydbfile.Seek(pos,CFile::begin);
//DEL sydbfile.Read(&ch,2);
//DEL while((ch!=0x0000)&&(sum<8))
//DEL {
//DEL m_yunmudesc[i][sum++]=ch;
//DEL sydbfile.Read(&ch,2);
//DEL };
//DEL m_yunmudesc[i][sum]='\0';
//DEL m_yunmudesc[i][0]=sum-1;
//DEL //m_yunmulen[i]=sum;
//DEL };
//DEL //////////////////////////////////////////////////////////////////////
//DEL //get all combiantion
//DEL /////////////////////////////////////////////////////////////////////
//DEL i=0;
//DEL pos=0;
//DEL DWORD temppos,tempcompos;
//DEL int nStart,nEnd;
//DEL int size;
//DEL WORD index;
//DEL m_combination[0][0]=24;
//DEL for(i=0;i<24;i++)
//DEL {
//DEL //////////////////////////////////////////////////////
//DEL // GetCombinationInx
//DEL //
//DEL temppos=0;
//DEL tempcompos=0;
//DEL nStart=0;
//DEL nEnd=0;
//DEL sydbfile.Seek(16,CFile::begin);
//DEL sydbfile.Read(&tempcompos,4);
//DEL pos=tempcompos+i*12;
//DEL sydbfile.Seek(pos+8,CFile::begin);
//DEL sydbfile.Read(&nStart,2);
//DEL sydbfile.Read(&nEnd,2);
//DEL //
//DEL // end of GetCombinationInx
//DEL /////////////////////////////////////////////////////
//DEL if ((nStart==0)&&(nEnd==0)) return;
//DEL sydbfile.Seek(24,CFile::begin);
//DEL sydbfile.Read(&pos,4);
//DEL size=nEnd-nStart+1;
//DEL pos+=(nStart-1)*12;
//DEL for(j=0;j<=size-1;j++)
//DEL {
//DEL sydbfile.Seek(pos,CFile::begin);
//DEL sydbfile.Read(&index,2);
//DEL m_combination[i+1][j+1]=index;
//DEL pos+=12;
//DEL };
//DEL m_combination[i+1][0]=size;
//DEL };
//DEL ///////////////////////////////
//DEL ///////////////////////////////////////////////////////////////////
//DEL sydbfile.Close();
//DEL
//DEL }
BOOL CRCIMEView::CanEscape()
{
if(isdrawing!=DRAW_SHENGMU) return TRUE;
else
return FALSE;
}
void CRCIMEView::EnableHZ(BOOL b)
{
if(b) m_IsShowHZ=TRUE;
else m_IsShowHZ=FALSE;
}
BOOL CRCIMEView::IsEnableHZ()
{
if(m_IsShowHZ) return(TRUE);
else return(FALSE);
}
void CRCIMEView::DrawNum(CDC *pDC, CPoint textoutpoint[], COLORREF clrnum,int hspan)
{
int i,wid=0;
char ch;
CString s;
CPoint p;
BOOL flag=TRUE;
if(!IsEnableHZ())
{
pDC->SetTextColor(m_clrdisable);
flag=FALSE;
};
//else
// pDC->SetTextColor(clrnum);
if((hspan-m_lfNum.lfWidth)>0)
wid=(hspan-m_lfNum.lfWidth)/2;
for(i=1;i<=9;i++)
{
p.x=textoutpoint[i+26].x+wid;
p.y=textoutpoint[i+26].y;
s.Empty();
ch=i+0x30;
s.Insert(0,ch);
if(flag) pDC->SetTextColor(m_clrBand[i-1]);
TextOut(pDC,p,s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -