You Are Here:

Community: Blogs

Li Yongfei's Forum Nokia Blog

Using Theme in an Application

cool_li | 22 May, 2006 15:54

Using Theme in an Application

This article can tell you how to write a enable skins application.
You can use theme in an Application after version in Series 60 Platform 2.0. the following content will tell you how to do these step by step.

Link against aknskins.lib and include files

Add the libray named aknskins.lib in SkinSample.mmp
 
Code:
LIBRARY aknskins.lib // link against aknskins.lib
Add two include files in SkinExampleContainer.h
 
Code:
#include <AknsDrawUtils.h>// add this inlcude file skin
#include <AknsBasicBackgroundControlContext.h> //add this inlcude file skin
 
Enabling skins in AppUi

Code:
/* In SkinExampleAppUi.cpp */
void CSkinExampleAppUi::ConstructL()
    {
    BaseConstructL( EAknEnableSkin );//Construct a enalbe skin
    .....
    }

new and delete a MAknsControlContext class in Container class

Add a MAknsControlContext class in container class

Code:
/* In skinExampleContainer.h */
class CSkinExampleContainer : public CCoeControl, MCoeControlObserver
{
 ....  
  private:
  MAknsControlContext* iBackGround; // for skins support 
}
 
/* In SkinExapleContainer.cpp */ 
void CSkinExampleContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
 
    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Skin Example") );
 
    SetRect(aRect);
    iBackGround = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, Rect(), EFalse );// new a background
    ActivateL();
    }
 
Delete iBackGroud

Code:
// Destructor
CSkinExampleContainer::~CSkinExampleContainer()
    {
   .....
 delete iBackGround;
    }
 

Draw the background bitmap using Skin library

Code:
/* In SkinExapleContainer.cpp */
void CSkinExampleContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
 // draw background
 MAknsSkinInstance* skin = AknsUtils::SkinInstance();//new
 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );//new
    AknsDrawUtils::Background( skin, cc, this, gc, aRect );//new
    }
 

MObjectProvider Chains

MObjectProvider interface can be used to make object instances available to child controls.
MopSupplyObject returns a pointer based on the given UID.
 
Code:
/* In SkinExapleContainer.cpp */
TTypeUid::Ptr CSkinExampleContainer::MopSupplyObject(TTypeUid aId)
    {
    if(aId.iUid == MAknsControlContext::ETypeId && iBackGround)
        {
        return MAknsControlContext::SupplyMopObject( aId, iBackGround);
        }
 
    return CCoeControl::MopSupplyObject( aId );
    }
Note: If you want to get the source code about this article ,plz link to http://www.symbianer.com.

RSSComments

Re: Using Theme in an Application

cool_li | 07/06/2006, 05:55

cool_li Welcome to discuss this article!

Re: Using Theme in an Application

slimpixi | 11/06/2006, 14:29

slimpixi OH MY GOSH! WHAT COUNTRY ARE YOU IN? ARE YOU IN FINLAND? if you are, please could we meet up and could we talk about the nokia themes? my name is anina and i am totally into making themes and i would really like to make the best themes. i need some help though to get my head around it. would you have some time on skype even to walk me through it?

my skype name:

anina.net

check out these themes i made, i am sure they could be improved a LOT!

http://anina.typepad.com/anina/2004/11/art_in_your_pho.html

dont be shocked, i worked with a very riske artist, fred casse from paris.

here too:

http://anina.typepad.com/anina/2005/01/ohm_me_up.html

so let me know by email to info@anina.net if you have time!

Re: Using Theme in an Application

cool_li | 12/06/2006, 07:53

cool_li Soryy! I am not in FINLAND, I am a chinese, if you need talk about the nokia themes, you can mail with me, or visit my website: http://www.symbianer.com

CEikLabel

alexbirkett | 09/04/2008, 20:07

Does the CEikLabel pick up it's text colour from the theme? This would be helpful.

can not finded the source code

linstime | 17/06/2008, 04:14

hi,
it is hard to find this source code in your site.pls get me an nicety linke,ok?

You must login to post comments. Login
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia