//固定长度显示多少个文字内容,ETrue是固定长度可以显示文字内容,EFalse是显示不下内容
//aFont使用的字体,aDes源字符串,aWidth显示的宽度,aLeft返回的值,当函数返回EFalse时候生效,从左到右取几个字符串
TBool CPreferContainer::CalcWord(const CFont * aFont, const TDesC & aDes, const TInt & aWidth , TInt & aLeft)
{
TInt nDotWidth = 10; //如果显示不下的情况,需要给字符串预留“...”的位置
aLeft = 0;
//如果一行显示不下,就截取前半部分,然后添加...
if (aFont->TextWidthInPixels(aDes) <= aWidth)
{
return ETrue;
}
else
{
aLeft = aFont->TextCount(aDes, aWidth - nDotWidth);
}
return EFalse;
}