×
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 change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix ReviewerApproval and ArticleMetaData)
Line 1: Line 1:
{{ReviewerApproved}}
 
{{ArticleMetaData
 
|id=
 
|platform= Symbian
 
|devices= S60 Emulator
 
|category= Symbian C++
 
|subcategory= S60 3rd FP1
 
|creationdate=September 29, 2009
 
|keywords= KAknsIIDQsnFrListCenter
 
  
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
+
{{ArticleMetaData <!-- v1.1 -->
 +
|sourcecode= [[Media:Tdjgmcqe(ListBoxItemHighlight).zip]]  
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= S60 Emulator
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= Symbian
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Chenziteng]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required (e.g. Location, NetworkServices.) -->
 +
|keywords= KAknsIIDQsnFrListCenter
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20090928
 +
|author= [[User:Chenziteng]]
 +
<!-- The following are not in current metadata -->
 +
|subcategory= S60 3rd FP1
 +
|category= Symbian C++
 
}}
 
}}
  
Line 61: Line 70:
  
 
[[Category:S60 3rd Edition]][[Category:Symbian C++]]
 
[[Category:S60 3rd Edition]][[Category:Symbian C++]]
 +
[[Category:Code Examples]]

Revision as of 06:29, 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):

Tdjgmcqe(ListBoxItemHighlight).zip

Screenshot:

Tdjgmcqe(ListBoxItemHighlight).PNG

131 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×