×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    73

    Changing Listbox text Color and highlight bar.

    Hi All,
    I am working on S60 3rd edition fp1. I am testing my application on 6110 Navigator phone. I am having my own custom background for my application. I am also changing the text color of the text in listbox and also the highlight bar that moves when we scroll the listbox.
    Everything works fine on the emulator. But when i test my application on the 6110 Navigator phone, the color of the text is that of the theme and the highlight bar is also of the theme. My customizations are not getting reflected (though it is working on the emulator). I am giving the code for reference. I want to know how to solve the problem

    Code:
    AppUi class
    
    void CCourierAutAppUi::ConstructL()
    {
    	// Initialise app UI with standard value.
       BaseConstructL(CAknAppUi::EAknEnableSkin);
    	
    	
    	
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    	
    	
       _LIT(KDrawBitmapPath, "\\resource\\apps\\CourierAut.mbm");
    	
       TFileName bitmapFile (KDrawBitmapPath);
      User::LeaveIfError(CompleteWithAppPath(bitmapFile));
    	
       CAknsItemDef* bgItemDef = AknsUtils::CreateBitmapItemDefL( KAknsIIDQsnBgAreaMain, bitmapFile, EMbmCourierautDark);
        
        
        skin->SetLocalItemDefL( bgItemDef ); //setting my custom background
    
    
    Container class
    
    void CCourierAutContainer2::ConstructL( const TRect& aRect)
    {
    
       CreateWindowL();
       iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,EFalse);
       CreateListL();
       iSavedInboxListBox->ItemDrawer()->ColumnData()->SetSkinEnabledL(EFalse);
       iSavedInboxListBox->SetListBoxObserver(this);
       
    SetRect( aRect );
        ActivateL();
        
        
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
        CAknsItemData* item = skin->GetCachedItemData(KAknsIIDQsnFrListCenter);
        
        if(item==NULL)
            {
            item = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListCenter);
            }
        
        _LIT(KMbmFile, "\\resource\\apps\\CourierAut.mbm");
    	
    	TFileName listbarFile (KMbmFile);
    	User::LeaveIfError(CompleteWithAppPath(listbarFile));
    	
    	if(item->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListCenter, KMbmFile, EMbmCourierautListbar, EMbmCourierautListbarmask);
            
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	
    	CAknsItemData* item2 = skin->GetCachedItemData(KAknsIIDQsnFrListSideB);
    	if(item2==NULL)
            {
            item2 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListSideB);
            }
    
    	if(item2->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListSideB, KMbmFile, EMbmCourierautListbarbot, EMbmCourierautListbarbotmask);
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	CAknsItemData* item3 = skin->GetCachedItemData(KAknsIIDQsnFrListSideT);
    	if(item3==NULL)
            {
            item3 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListSideT);
            }
    
    	if(item3->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListSideT, KMbmFile, EMbmCourierautListbarbot, EMbmCourierautListbarbotmask);
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	CAknsItemData* item4 = skin->GetCachedItemData(KAknsIIDQsnFrListSideL);
    	if(item4==NULL)
            {
            item4 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListSideL);
            }
    
    	if(item4->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListSideL, KMbmFile, EMbmCourierautListbarside, EMbmCourierautListbarsidemask);
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	CAknsItemData* item5 = skin->GetCachedItemData(KAknsIIDQsnFrListSideR);
    	if(item5==NULL)
            {
            item5 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListSideR);
            }
    
    	if(item5->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListSideR, KMbmFile, EMbmCourierautListbarside, EMbmCourierautListbarsidemask);
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	CAknsItemData* item6 = skin->GetCachedItemData(KAknsIIDQsnFrListCornerTl);
    	if(item6==NULL)
            {
            item6 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListCornerTl);
            }
    
    	if(item6->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListCornerTl, KMbmFile, EMbmCourierautListbarside, EMbmCourierautListbarsidemask);
            skin->SetLocalItemDefL(def);
            }
    	
    	CAknsItemData* item7 = skin->GetCachedItemData(KAknsIIDQsnFrListCornerTr);
    	if(item7==NULL)
            {
            item7 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListCornerTr);
            }
    
    	if(item7->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListCornerTr, KMbmFile, EMbmCourierautListbarside, EMbmCourierautListbarsidemask);
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	CAknsItemData* item8 = skin->GetCachedItemData(KAknsIIDQsnFrListCornerBl);
    	if(item8==NULL)
            {
            item8 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListCornerBl);
            }
    
    	if(item8->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListCornerBl, KMbmFile, EMbmCourierautListbarside, EMbmCourierautListbarsidemask);
            skin->SetLocalItemDefL(def);
            }
    	
    	
    	CAknsItemData* item9 = skin->GetCachedItemData(KAknsIIDQsnFrListCornerBr);
    	if(item9==NULL)
            {
            item9 = skin->CreateUncachedItemDataL(KAknsIIDQsnFrListCornerBr);
            }
    
    	if(item9->Type()==EAknsITMaskedBitmap)
            {
            CAknsItemDef* def = AknsUtils::CreateMaskedBitmapItemDefL(KAknsIIDQsnFrListCornerBr, KMbmFile, EMbmCourierautListbarside, EMbmCourierautListbarsidemask);
            skin->SetLocalItemDefL(def);
            }
    
    
    }
    
    void CCourierAutContainer2::CreateListL()
    	{
    	
    	iSavedInboxListBox = new (ELeave) CAknSingleStyleListBox;
    	iSavedInboxListBox->SetContainerWindowL(*this);
    	
    	// Second Phase Construction
    	TResourceReader reader;
    	CEikonEnv::Static()->CreateResourceReaderLC(reader, R_DYNAMICLIST_SAVED_INBOX_LISTBOX);
    	iSavedInboxListBox->ConstructFromResourceL(reader);
    	CleanupStack::PopAndDestroy(); // reader
    	}
    
    void CCourierAutContainer2::Draw( const TRect& aRect ) const
        {
        CWindowGc& gc = SystemGc();
        
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
        MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
        AknsDrawUtils::Background( skin, cc, this, gc, aRect );
     
        ....
        TRgb colorval = TRgb(248,175,7);
    
    
    //    iSavedInboxListBox->ItemDrawer()->SetTextColor(KRgbRed);
        iSavedInboxListBox->ItemDrawer()->SetTextColor(colorval);
        
      //  iSavedInboxListBox->ItemDrawer()->SetHighlightedTextColor(KRgbGreen);
        iSavedInboxListBox->ItemDrawer()->SetHighlightedTextColor(KRgbWhite);
       }

    thanks and regards,
    Krishna.

  2. #2
    Nokia Developer Expert
    Join Date
    Feb 2008
    Posts
    183

    Re: Changing Listbox text Color and highlight bar.

    Have you tried to use CCoeControl::OverrideColorL?
    At least in some cases it works for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×