Symbian 中大段文本显示控件详解
2010-02-22 20:53:00 来源:WEB开发网}
}
}
delete CopyText;
}
else
{
iDisplayContent->Append(CopyText);
}
//获取一屏幕显示的行数
//计算文字显示总行数
AccountTotalLine();
CreateScrollBars(iTotalLine-iMaxDisplayLine+2);
}
void CTextDisplay::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetBrushColor(iBackGround);
gc.Clear(aRect);
gc.UseFont(iFont);
gc.SetPenColor(iFontColour);
//起点
TPoint point = iStartPoit;
//记录上一段的位置
TPoint Mark = TPoint(0,-(iStartLine*iFont->HeightInPixels()+iLineToLineSpace));
TPoint point2;
if(iDisplayContent == NULL)
{
gc.DrawText(_L("No content!"),TPoint(aRect.Width()/3,aRect.Height()/3));
return ;
}
for(TInt i=0;i
{
TInt nStringMaxDisplayLine = iFont->TextWidthInPixels((*iDisplayContent)[i]->Des())/(iRect.Width() - iScrollBarWidth) + iMaxDisplayLine;
TBidiText* bidi = TBidiText::NewL((*iDisplayContent)[i]->Des(), nStringMaxDisplayLine);
bidi->WrapText(iRect.Width()-iScrollBarWidth, *iFont, NULL);
TInt lines = bidi->NumberOfLinesInDisplayText();
for(TInt i=0; i
{
point2 = TPoint (point.iX,point.iY+Mark.iY + iFont->HeightInPixels()*(i+1)+iLineToLineSpace*i);
TInt width = 0;
TPtrC text = bidi->LineOfDisplayText(i, width);
gc.DrawText(text, point2);
}
Mark = point2;
delete bidi;
}
//画个小三角
if(Mark.iY > iRect.Height() - LASTSPACE || iStartLine > 0)
更多精彩
赞助商链接