Namespaces
Variants
Actions

Archived:How to retrieve grid text color from the current theme on Symbian

Jump to: navigation, search
Archived.png
Archived: 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

Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition

Article
Created: User:Technical writer 2 (22 Feb 2007)
Last edited: hamishwillee (15 Jun 2012)

Overview

How to retrieve grid text color from the current theme

Description

The text color for custom grids (CAknGrid) can be retrieved from the current theme. Setting the grid text color is slightly different for S60 2nd Edition and 3rd Edition devices.

Solution

S60 2nd Edition:
Normal and highlighted text colors can be set in the SizeChanged() function of the CCoeControl-derived container (that owns the grid). The following code demonstrates this:
    TRgb textColor; // text color when not highlighted
    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG9 );
    TRgb highlightColor; // text color when highlighted
    AknsUtils::GetCachedColor( skin, highlightColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 );
    iGrid->ItemDrawer()->SetTextColor( textColor ); // iGrid is of type CAknGrid
    iGrid->ItemDrawer()->SetHighlightedTextColor( highlightColor );
However, ItemDrawer()->SetTextColor() cannot be used for S60 3rd Edition and higher.
S60 3rd Edition:
Set the color of a CFormattedCellListBoxData object. This can be done as follows:
    TRgb textColor; // text color when not highlighted
    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG9 );
    TRgb highlightColor; // text color when highlighted
    AknsUtils::GetCachedColor( skin, highlightColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 );

    CFormattedCellListBoxData::TColors colors;
    colors.iText = textColor;
    colors.iHighlightedText = highlightColor;
    iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 0, colors );
    iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 1, colors );
    iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL( 3, colors );
The above code has to be added to the SizeChanged() function of the grid, otherwise the default SizeChanged() implementation will override the custom settings. Also note that the SetUpFormTextCell() method of grid has to be called before trying to set the text colors.

This page was last modified on 15 June 2012, at 04:29.
196 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