Using Theme in an Application--在应用中使用主题(Symbian)
2007-11-19 19:41
736 查看
This article can tell you how to write a enable skins application.
You can use theme in an Application after version in S60 Platform 2nd Edition. the following content will tell you how to do these step by step.
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;
}
/* 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
}
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 );
}
download SkinExample.SIS(For S60 2rd FP3)
download source code SkinExample.rar
转载自:http://www.symbianer.com/post/3.html
You can use theme in an Application after version in S60 Platform 2nd Edition. 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.mmpCode:
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 );
}
download SkinExample.SIS(For S60 2rd FP3)
download source code SkinExample.rar
转载自:http://www.symbianer.com/post/3.html
附: windcao在csdn博客上的一篇文章地址: symbian系统皮肤(theme)使用方法汇总 地址:http://blog.csdn.net/windcao/archive/2007/09/10/1779413.aspx |
相关文章推荐
- Using Theme in an Application
- Using Theme in an Application
- 使用apt导入时报警告:Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
- How To Customise the Tab Bar (UITabBar) in an iPhone Application (Part 1 of 2)
- Using the Enterprise Library Validation Application Block in ASP.NET - Part I
- web服务器和应用服务器的区别(the difference between an application server and a Web server)
- An Inline Function is As Fast As a Macro(《Using the GNU Compiler Collection (GCC)》)
- 关于C++程序运行程序是出现的this application has requested the runtime to terminate it in an unusual way. 异常分析
- 1.4 Dynamically change the look of an application by using view states,transitions and effects
- 在响应链中使用视图控制器Using View Controllers in the Responder Chain[苹果官方文档的翻译]
- Using Styles and Themes in Android(在Android中使用主题和样式)
- Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application
- An error message detailing the cause of this specific request failure can be found in the application event log of the
- Centos下_MysqL5.7在使用mysqldump命令备份数据库报错:mysqldump: [Warning] Using a password on the command line interface can be insecure.
- 使用伪寄存器调试MSVC++程序的介绍--An introduction to debugging in MSVC++ using Pseudoregisters
- Using button controls in an application
- 错误信息:This application has requested the Runtime to terminate it in an ...
- Spring Boot 项目构建 之 使用 Spring Boot 构建应用(Building an Application with Spring Boot)
- How To Customise the Tab Bar (UITabBar) in an iPhone Application (Part 2 of 2)
- 使用缓存管理器,尽你之能力(Cache Me if You Can: Using the NT Cache Manager )