系统皮肤(theme)使用方法汇总(转)

系统皮肤(theme)使用方法汇总
作者:算-法无极    文章来源:blog.csdn.net/windcao    更新时间:2007-10-15 9:43:44 

使用symbian应用程序创建向导可以创建带有皮肤支持的工程。使得你的应用程序可以很方便的使用系统皮肤。
创建方法如下:
1打开开始菜单s60sdk的目录下Tools 然后选择Application Wizard创建一个app
2在第二个向导页面上你可以看到Add support for的选项,选择下面的skins然后继续创建。你就可以得到一个支持皮肤的工程了。

如果是一个已有工厂以前没有支持皮肤功能,也可以手工添加。步骤如下

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 );
放在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 的
MopSupplyObject(TTypeUid aId)
{
    if(aId.iUid == MAknsControlContext::ETypeId && iBackGround)
        {
        return MAknsControlContext::SupplyMopObject( aId, iBackGround);
        }
    return CCoeControl::MopSupplyObject( aId );
}

原文地址:https://www.cnblogs.com/yaoliang11/p/1875526.html