Enable Skin support in your Symbian OS applications
来源:互联网 发布:淘宝一手货源网 编辑:程序博客网 时间:2024/05/17 05:10
Nokia has introduced skin support in S60 v2. For various reasons, including compatibility with S60 v1 and thus older devices, this support is not enabled by default: your application will display a not so original white background unless you code it differently.
A nice and user-friendly way to behave is to use the mobile theme skin as a background for your application. Unless very badly documented in the SDK so far, this is not that complex for most applications. Here is an example implementation.
Application UI
The impact in your application UI is quite limited. All you have to do is to enable skins when calling the AppUi base constructor:
Application View or Containers
As you may have guessed, the main changes will be in your view and containers. The changes here may vary from simple to rather complex depending on what your are trying to achieve. Unfortunately, the Skin API is not very well documented and everything here is not always compatible in S60 3rd Edition... [1]
First, you need to create a specific context to hold the skin bitmap for your control. Do this by adding the following data member to your view/container class:
CAknsBasicBackgroundControlContext* iBgContext;
And initialize properly in the corresponding ConstructL, initialise a reference to the background bitmap:
Don't forget to call the corresponding destructor:
This context shall be passed to the child controls so that they can redisplay themselves correctly. This is done throgh MOP relationship and you then need to override the MopSupplyObject() primitive as follow:
Each control Draw primitive shall now be updated to display the skin as background:
And finally:
If your control contains a listbox, you can enable skin behind the items by calling:
iListBox->ItemDrawer()->ColumnData()->SetSkinEnabledL(ETrue)
MMP File
And finally, you need to link against the Avkon Skin libraries. Add the following line in your MMP file:
LIBRARY aknskins.lib aknskinsrv.lib
{
if(iBgContext)
{
iBgContext->SetRect(Rect());
if ( &Window() )
{
iBgContext->SetParentPos( PositionRelativeToScreen() );
}
}
}
void CSkinDemoAppView::Draw(const TRect& aRect) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Redraw the background using the default skin
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
AknsDrawUtils::Background( skin, cc, this, gc, aRect );
...
}
{
if (iBgContext )
{
return MAknsControlContext::SupplyMopObject( aId, iBgContext );
}
return CCoeControl::MopSupplyObject(aId);
}
{
...
delete iBgContext;
...
}
#include <AknsBasicBackgroundControlContext.h>
...
void CSkinDemoAppView::ConstructL()
{
...
iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,ETrue);
...
}
void CSkinDemoAppUi::ConstructL()
{
BaseConstructL(EAknEnableSkin);
...
}
- Enable Skin support in your Symbian OS applications
- Enable Skin support in your Symbian OS applications
- Debugging JavaScript in Your Applications
- j2me入门-symbian os support for MIDP
- Three steps to enable your NLS support on IBM i
- Use Shell ContextMenu in your applications
- Enable WebGL Support For Google Chrome In Linux
- Why doesn't Symbian OS support writeable static data?
- Why doesn't Symbian OS support writeable static data?
- Enable VT-x in your BIOS 怎么解决
- Writing a DLL (used in Symbian OS)
- Resource file in Symbian OS Application
- System panic reference in Symbian OS reference
- Preventing Cross-site Scripting Attacks--In Your Web Applications
- Using your own SQLite database in Android applications
- Using your own SQLite database in Android applications
- Using SQLite in your Windows 8 Metro style applications
- Using SQLite in your Windows 8 Metro style applications
- 深入理解JAVA事件机制
- sql的select查询列名未确定的问题
- 回调函数和函数指针
- Windows 消息机制
- 激励人生的10张海报
- Enable Skin support in your Symbian OS applications
- 宽字符跟ASCII——区别及测试
- 客户端无字体时的做法
- xp下用户程序空间分配(7):Heap
- VS2005把我弄晕了
- 在struts2.0中指定日期的输入输出格式
- DateTime 格式
- 2009-08-28
- 最近居然在研究openVMS