|
|
Classification: |
C++ |
Category: |
Text Layout & Formatting |
Created: |
01/14/2002 |
Modified: |
01/14/2002 |
Number: |
FAQ-0763 |
Platform: |
ER5, Symbian OS v6.0, Symbian OS v6.1 |
|
Question: I have tried to modify the background colour of a CTextView object with the following code, but the text background colour
remains the default white. What is wrong?
iLayout=CTextLayout::NewL(iGlobalText,iViewRect.Width()); CleanupStack::PushL(iLayout); iTextView=CTextView::NewL(iLayout, iViewRect, device, device, &Window(), 0, &iCoeEnv->WsSession() ); CleanupStack::Pop(); // iLayout iTextView->SetBackgroundColor(KRgbPurple);
Answer: The SetBackgroundColor() method of CTextView modifies the colour only of that part of its view rect which is not occupied by the paragraph of text inserted.
You need to modify not the background colour of the CTextView but the iFillColor property of the CParaFormat object associated with the CGlobalText object itself. Creating the CGlobalText object using the following code accomplishes this:
iParaFormatLayer=CParaFormatLayer::NewL(); // required para format layer CleanupStack::PushL(iParaFormatLayer); iCharFormatLayer=CCharFormatLayer::NewL(); // required char format layer CleanupStack::PushL(iCharFormatLayer); TParaFormatMask mask; mask.SetAttrib(EAttFillColor); CParaFormat paraFormat; const TLogicalRgb KPurple = TLogicalRgb(0x00A000A0); paraFormat.iFillColor = KPurple; iParaFormatLayer->SetL(¶Format, paraMask); iGlobalText=CGlobalText::NewL(iParaFormatLayer, iCharFormatLayer); CleanupStack::PushL(iGlobalText);
The last two lines of the cited code should then be replaced by
CleanupStack::Pop(4); // iLayout, iGlobalText, iCharFormatLayer, iParaFormatLayer
|
|
|