转贴自:http://wiki.forum.nokia.com/index.php/CS001459_-_Skinning_the_application
ID | CS001459 | Creation date | September 8th, 2009 |
Platform | S60 3rd Edition FP2, S60 5th Edition | Tested on devices | Nokia N78, Nokia 5800 XpressMusic |
Category | Symbian C++ | Subcategory | UI, Themes |
Overview
This code can be used to skin the application using MAknsSkinInstance.
MMP file
The following capabilities and libraries are required:
CAPABILITY ReadUserData
LIBRARY aknskins.lib aknskinsrv.lib aknswallpaperutils.lib
Header file
//includes
#include <aknsutils.h>
#include <AknsItemDef.h>
#include <aknsskininstance.h>
Source file
This code can be used to change the skin background:
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
TAknsItemID elementID;<br>
//Changing the status pane skin background
elementID.Set(EAknsMajorSkin, EAknsMinorQsnBgAreaStatus);
skin->SetLocalItemDefL(AknsUtils::CreateBitmapItemDefL(elementID,KMbmFileName,EMbmSkinchange_0xe5c4b7eeGray));<br>
//Changing the navi pane skin background
elementID.Set(EAknsMajorAvkon, EAknsMinorQsnBgNavipaneSolid);
skin->SetLocalItemDefL(AknsUtils::CreateBitmapItemDefL(elementID,KMbmFileName,EMbmSkinchange_0xe5c4b7eePink));<br>
//Changing the list background
elementID.Set(EAknsMajorSkin, EAknsMinorQsnBgAreaMainListGene);
skin->SetLocalItemDefL(AknsUtils::CreateBitmapItemDefL(elementID,KMbmFileName,EMbmSkinchange_0xe5c4b7eeGray));
//Changing the control pane skin background
elementID.Set(EAknsMajorSkin, EAknsMinorQsnBgAreaControl);
skin->SetLocalItemDefL(AknsUtils::CreateBitmapItemDefL(elementID,KMbmFileName,EMbmSkinchange_0xe5c4b7eeGray));
This code can be used to change the text colors:
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
CAknsItemData* itemData = skin->GetCachedItemData(KAknsIIDQsnTextColors, EAknsITColorTable);
CAknsColorTableItemData* colorItemData = static_cast<CAknsColorTableItemData*>(itemData);
TAknsColorTableEntry textColors[50];
for (TInt i = 0; i < 50; i++)
{
TUint32 color;
switch (i)
{
case EAknsCIQsnTextColorsCG1: //status area title text
case EAknsCIQsnTextColorsCG2: //navi pane texts
{
color = 0xFF0000;
}
break;<br>
case EAknsCIQsnTextColorsCG3: //active tab text
case EAknsCIQsnTextColorsCG4: //passive tab text
{
color = 0x00FF00;
}
break;<br>
case EAknsCIQsnTextColorsCG10: //list highlight list texts
{
color = 0x00FF00;
}
break;<br>
case EAknsCIQsnTextColorsCG13: //control pane general left softkey text
case EAknsCIQsnTextColorsCG14: //control pane general right softkey text
case EAknsCIQsnTextColorsCG15: //control pane idle left softkey text
case EAknsCIQsnTextColorsCG16: //control pane idle right softkey text
{
color=0xFF0000;
}
break;<br>
default:
{
color = colorItemData->ColorRgb(i).Value();
}
break;
}
textColors[i].iIndex=-1;
textColors[i].iRgb=color;
}
colorItemData->SetColorsL(50, textColors);