Symbian 字体汇总

 

获取系统字体颜色:

 

标题:如何从当前主题中获取grid文本颜色
TSS000596

设备, 软件 版本: 
S60 2nd Edition, S60 3rd Edition

详细描述
我们可以从当前主题中获取自定义grid(CAknGrid)的文本颜色,但在设置时第二版和第三版略有不同。

解决方案
S60第二版:
正常状态下以及高亮状态下,可以在CCoeControl派生的Container的SizeChanged()方法中设置(该Container拥有grid)。下列是示例代码:
Code:
    TRgb textColor; // text color when not highlighted  ---- 系统字体颜色

    MAknsSkinInstance* skin = AknsUtils::SkinInstance(); 

    AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG9 );

    TRgb highlightColor; // text color when highlighted

    AknsUtils::GetCachedColor( skin, highlightColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 );
    iGrid->ItemDrawer()->SetTextColor( textColor ); // iGrid is of type CAknGrid

    iGrid->ItemDrawer()->SetHighlightedTextColor( highlightColor );
但这里ItemDrawer()->SetTextColor()方法无法用在S60第三版上。


S60第三版:
设置颜色要通过CFormattedCellListBoxData对象,可以做如下操作:
Code:
    TRgb textColor; // text color when not highlighted 

    MAknsSkinInstance* skin = AknsUtils::SkinInstance(); 

    AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG9 );

    TRgb highlightColor; // text color when highlighted

    AknsUtils::GetCachedColor( skin, highlightColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 );

    

    CFormattedCellListBoxData::TColors colors;

    colors.iText = textColor;

    colors.iHighlightedText = highlightColor;

    iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 0, colors );

    iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 1, colors );

    iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 3, colors );

上面的代码可以加载在grid的SizeChanged()函数中,否则默认的SizeChanged()会覆盖自定义的操作。注意SetUpFormTextCell()函数的调用必须要在设置文本颜色前调用。

 

 


自定义字体大小

 

CFont* normalFont = NULL;
TFontSpec fontSpec = iEikonEnv->NormalFont()->FontSpecInTwips();
fontSpec.iHeight /= 2;
iCoeEnv->ScreenDevice()->GetNearestFontInTwips(normalFont, fontSpec);
if (normalFont != NULL)
{
     // normalFont can be used now!
}
iCoeEnv->ScreenDevice()->ReleaseFont(normalFont);
获得字体的宽度
eg
TInt pos = normalFont->TextWidthInPixels(title->Des());
 
CFont::CharWidthInPixels(),CFont::MaxCharWidthInPixels(),CFont::MaxNormalCharWidthInPixels(),CFont::TextWidthInPixels()

 

 

windcao发表与:http://blog.csdn.net/windcao/archive/2007/09/05/1773637.aspx

先看看代码,由于标签的原有有些内容有误,
 gc.DrawText(_L("SymbolFont /x671D/x5916/x5927/x8857"),TPoint(x,baseH));
被显示成了    gc.DrawText(_L("SymbolFont g1DY16Y27ˆ57"),TPoint(x,baseH));
实际上/x671D/x5916/x5927/x8857是汉字 朝外大街。

获取固定大小的字体:

void CTestView::Draw( const TRect&  /*aRect*/ ) const
     {
                    // Get the standard graphics context
                    CWindowGc& gc = SystemGc();

                    // Gets the control's extent
                    TRect drawRect( Rect());

                    // Clears the screen
                     gc.Clear( drawRect );
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值