Using Theme in an Application
2006-07-11 10:02
459 查看
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.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 );
}
Note: If you want to get the source code about this article ,plz contact me.
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=751487
相关文章推荐
- Using Theme in an Application
- Using Theme in an Application--在应用中使用主题(Symbian)
- 错误信息:This application has requested the Runtime to terminate it in an ...
- [TypeScript] Find the repeated item in an array using TypeScript
- Hack the Stack: Using Snort and Ethereal to Master the 8 Layers of an Insecure Network [ILLUSTRATED]
- An Inline Function is As Fast As a Macro(《Using the GNU Compiler Collection (GCC)》)
- Accessing the active space or layout in an AutoCAD drawing using .NET
- How To Answer The Question "tell me about yourself" In An Interview
- 虚拟机the virtual machine is in use by an application
- How to access the features in an in-memory output layer using an IFeatureCursor
- Using Timer to get history values from EDNA database, an error is prompted in the page : "Sys.WebForms.PageRequestManagerTimeout
- 程序运行程序是出现的this application has requested the runtime to terminate it in an unusual way. 异常分析
- This application has requested the Runtime to terminate it in an unusual way
- Using iCloud Storage in an iOS 5 iPhone Application
- A 2007 Office system application does not load an add-in that is developed by using VSTO
- This application has requested the Runtime to terminate it in an unusual way. Please contact the app
- How to write an application that supports the Fast User Switching feature by using Visual Basic .NET or Visual Basic
- Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application (9 of 10)
- How to access the features in an in-memory output layer using an IFeatureCursor
- This application has requested the Runtime to terminate it in an unusual way.