Using Theme in an Application

原创 2006年05月23日 16:51:00

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.
Author Website: http://www.symbianer.com

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 contact me.

相关文章推荐

Using iCloud Storage in an iOS 5 iPhone Application

Previous Table of Contents Next Managing iPhone Files using the iOS 5 UIDocument Class   ...

Create an Asp.Net Web Forms Application using Bootstrap and Web API

http://www.codeproject.com/Articles/815916/How-To-Create-an-Asp-Net-Web-Forms-Application-usi
  • dc8899
  • dc8899
  • 2014年09月11日 00:41
  • 1173

A C3P0Registry mbean is already registered.This probably means that an application using c3p0的警告信息处理

系统在启动的时候c3p0报警告信息“A C3P0Registry mbean is already registered. This probably means that an applicatio...

1.4 Dynamically change the look of an application by using view states,transitions and effects

1.示例代码如下:

SpringBoot之Using WebSocket to build an interactive web application

通过 STOMP来简单实现WebSocket的交互。1 服务端接收的消息model类package websocket.interactive.web.application.hello;public...

To upload an excel file using WebDynpro Application.

Scenario:To upload an excel file using WebDynpro Application. Procedure: 1. Go to transac...

两个用C实现遗传算法的程序 an example of a very simple genetic algorithm in C and a GA implementation using binary and real coded variables

/* ga.c is an example of a very simple genetic algorithm in C */ & /***************************...
  • amu0421
  • amu0421
  • 2011年05月26日 18:23
  • 788
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Using Theme in an Application
举报原因:
原因补充:

(最多只允许输入30个字)