×
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)
hamishwillee (Talk | contribs)
m (Hamishwillee - Adding missing translation link)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:S60 3rd Edition]][[Category:Symbian C++]][[Category:Code Examples]]
+
{{Archived|timestamp=20120313095721|user=roy.debjit| }}
{{ArticleMetaData <!-- v1.1 -->
+
[[Category:S60 3rd Edition (initial release)]][[Category:Symbian C++]][[Category:Code Examples]]
|sourcecode= [[Media:Tdjgmcqe(ListBoxItemHighlight).zip]]  
+
{{ArticleMetaData <!-- v1.2 -->
 +
|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]]) -->
 
|devices= S60 Emulator
 
|devices= S60 Emulator
Line 9: Line 10:
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
|capabilities= <!-- Capabilities required (e.g. Location, NetworkServices.) -->
+
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|keywords= KAknsIIDQsnFrListCenter
 
|keywords= KAknsIIDQsnFrListCenter
|id= <!-- Article Id (Knowledge base articles only) -->
 
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->
Line 24: Line 24:
 
<!-- The following are not in current metadata -->
 
<!-- The following are not in current metadata -->
 
|subcategory= S60 3rd FP1
 
|subcategory= S60 3rd FP1
|category= Symbian C++
 
 
}}
 
}}
 +
 
  
 
== Overview ==
 
== Overview ==
Line 68: Line 68:
  
 
[[File:Tdjgmcqe(ListBoxItemHighlight).PNG]]
 
[[File:Tdjgmcqe(ListBoxItemHighlight).PNG]]
 +
<!-- Translation --> [[zh-hans:如何改变列表框当前项的背景]]

Latest revision as of 08:58, 18 September 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

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


[edit] 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);
*/

}

[edit] 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

This page was last modified on 18 September 2012, at 08:58.
84 page views in the last 30 days.