×
Namespaces

Variants
Actions
(Difference between revisions)

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

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix ReviewerApproval and ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Tidy wiki text)
Line 1: Line 1:
 
+
[[Category:S60 3rd Edition]][[Category:Symbian C++]][[Category:Code Examples]]
 
{{ArticleMetaData <!-- v1.1 -->
 
{{ArticleMetaData <!-- v1.1 -->
 
|sourcecode= [[Media:Tdjgmcqe(ListBoxItemHighlight).zip]]  
 
|sourcecode= [[Media:Tdjgmcqe(ListBoxItemHighlight).zip]]  
Line 27: Line 27:
 
}}
 
}}
  
= Overview =
+
== 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.
 
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.
Line 59: Line 59:
 
</code>
 
</code>
  
= Source Code =
+
== Source code ==
  
 
Full example (you should change the hard-coded mbm path in order to run it on target):  
 
Full example (you should change the hard-coded mbm path in order to run it on target):  
  
[[:File:Tdjgmcqe(ListBoxItemHighlight).zip|Tdjgmcqe(ListBoxItemHighlight).zip]]
+
[[File:Tdjgmcqe(ListBoxItemHighlight).zip]]
  
 
Screenshot:
 
Screenshot:
  
 
[[File:Tdjgmcqe(ListBoxItemHighlight).PNG]]
 
[[File:Tdjgmcqe(ListBoxItemHighlight).PNG]]
 
[[Category:S60 3rd Edition]][[Category:Symbian C++]]
 
[[Category:Code Examples]]
 

Revision as of 07:21, 14 February 2012

Article Metadata
Code ExampleTested with
Devices(s): S60 Emulator
CompatibilityArticle
Keywords: KAknsIIDQsnFrListCenter
Created: chenziteng (28 Sep 2009)
Last edited: hamishwillee (14 Feb 2012)

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):

File:Tdjgmcqe(ListBoxItemHighlight).zip

Screenshot:

Tdjgmcqe(ListBoxItemHighlight).PNG

117 page views in the last 30 days.
×