A CEikLabel is a basic component use to display static text in a control. It is fairly easy and straightforward to use as soon as you don’t have to change its color: there is no SetColor() primitive.
If you are reading this page, you are probably looking for the answer. And as usual in the Symbian world, it is pretty trivial once you know how to do it. As a matter of fact, you have to override the EColorLabelTextEmphasis setting of your label using the OverrideColorL() primitive and then to activate the setting, using SetEmphasis(). The code below shows how to do this:
#include <gulcolor.h>
...
// Basic Label Construction
CEikLabel* myLabel;
myLabel= new (ELeave) CEikLabel;
myLabel->SetContainerWindowL( *this );
myLabel->SetTextL( _L("NewLC rulez!") );
// Now Set the foreground color to Red
myLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbRed );
myLabel->SetEmphasis( CEikLabel::EPartialEmphasis );
Alternatively you may want to specify a foreground AND a background color. In this case, you also have to override and activate the EColorLabelHighlightFullEmphasis setting:
// Now Set the foreground Color to White
// and the background color to Red
myLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbWhite );
myLabel->OverrideColorL( EColorLabelHighlightFullEmphasis, KRgbRed );
myLabel->SetEmphasis( CEikLabel::EFullEmphasis );
|