Namespaces
Variants
Actions
(Difference between revisions)

Archived:How to change the highlighted listbox item background using Symbian C++

Jump to: navigation, search
m (spelling and " < Code cpp >)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
  
On S60 3rd Edition the listbox is fully skinnable, and the listbox item background is actually an image that is stitched together by nine small images (four edges, four corners and the central image). Every part is identified by an ID like the KAknsIIDQsnFrListCenter. You can find the definition of the IDs in the system header file AknsConstants.h.
+
On S60 3rd Edition the list-box is fully skinned, and the list-box item background is actually an image that is stitched together by nine small images (four edges, four corners and the central image). Every part is identified by an ID like the KAknsIIDQsnFrListCenter. You can find the definition of the IDs in the system header file AknsConstants.h.
  
The following code shows how to override the skin image for listbox highlighted item background (central part) by a self-created bitmap.
+
The following code shows how to override the skin image for list-box highlighted item background (central part) by a self-created bitmap.
  
<code>
+
<code cpp>
 
void CTdjgmcqeListBox::ConstructL(  
 
void CTdjgmcqeListBox::ConstructL(  
 
const TRect& aRect,  
 
const TRect& aRect,  

Revision as of 11:41, 28 September 2009

Overview

On S60 3rd Edition the list-box is fully skinned, and the list-box item background is actually an image that is stitched together by nine small images (four edges, four corners and the central image). Every part is identified by an ID like the KAknsIIDQsnFrListCenter. You can find the definition of the IDs in the system header file AknsConstants.h.

The following code shows how to override the skin image for list-box highlighted item background (central part) by a self-created bitmap.

void CTdjgmcqeListBox::ConstructL( 
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
...
_LIT(KMbmFile, "z:\\resource\\apps\\Tdjgmcqe.mbm"); // not good to use a hard-coded path, but anyway this is just a sample code.
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
CAknsItemData* item = skin->GetCachedItemData(KAknsIIDQsnFrListCenter);
if(item==NULL)
{
item = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListCenter);
}
if(item->Type()==EAknsITMaskedBitmap)
{
CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListCenter, KMbmFile, EMbmTdjgmcqeListboxitemhightlightcenter, EMbmTdjgmcqeListboxitemhightlightcentermask);
skin->SetLocalItemDefL(def);
}
/*
// change the highlighted item text color
iListBox->ItemDrawer()->SetHighlightedTextColor(KRgbRed);
*/

}

Source Code

Full example (you should change the hard-coded mbm path in order to run it on target):

Tdjgmcqe(ListBoxItemHighlight).zip

Screenshot:

Tdjgmcqe(ListBoxItemHighlight).PNG

228 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved