使用系统自带皮肤

 1) 在ui里面 ui ConstructL函数里面将原来的BaseConstructL();换成BaseConstructL( EAknEnableSkin );

2) Container 里面加入头文件
#include <AknsBasicBackgroundControlContext.h> //skin

3) container里面添加成员变量 并在ConstructL里面初始化它。
.h里面加成员变量  MAknsControlContext* iBackGround; // for skins support
.cpp里面ConstructL里初始化

SetRect(aRect);
 iBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse );

在~containter里

if(iBackGround)

{

    delete  iBackGround;

    iBackGround = NULL;

}
放在setrect之后!!!!!!!否则无法看到皮肤

4) Container 的
Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
 // draw background
 MAknsSkinInstance* skin = AknsUtils::SkinInstance();
 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
    AknsDrawUtils::Background( skin, cc, this, gc, aRect );
    }

5)在 Container 定义一个这样的函数
TTypeUid::Ptr MopSupplyObject(TTypeUid aId)
{
    if(aId.iUid == MAknsControlContext::ETypeId && iBackGround)
        {
        return MAknsControlContext::SupplyMopObject( aId, iBackGround);
        }
    return CCoeControl::MopSupplyObject( aId );
}

用下面的方法我们可以获取系统皮肤的相关颜色:

    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    TRgb color;
    AknsUtils::GetCachedColor(skin,color,KAknsIIDQsnScrollColors,EAknsCIQsnIconColorsCG10);

 

*注: 使用AknsUtils 需要包含#include <aknsutils.h>
       AknsDrawUtils 需要#include <aknsdrawutils.h>

 

     还有要用到aknskins.lib

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值