×
Namespaces

Variants
Actions
Revision as of 09:23, 14 June 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Applying background color for paragraphs in a CEikRichTextEditor

From Nokia Developer Wiki
Jump to: navigation, search

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
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition FP1
Article
Created: User:Technical writer 2 (29 Dec 2006)
Last edited: hamishwillee (14 Jun 2012)

Overview

Applying background color for paragraphs in a CEikRichTextEditor

Description

When using a rich text editor (CEikRichTextEditor) with multiple paragraphs, it is possible to distinguish between paragraphs or to highlight one by applying a unique background color.
The following simple code snippet explains how to create a rich text editor and how to apply unique background colors for each paragraph.
    iEditor = new ( ELeave ) CEikRichTextEditor;
    iEditor->SetContainerWindowL( *this );
    iEditor->ConstructL( this, 0, 0, 0 );
    iEditor->SetRect( iEditorRect );
    CRichText* richtext = iEditor->RichText();
    CParaFormat* pf = new ( ELeave ) CParaFormat;
    CleanupStack::PushL( pf );
    pf->iFillColor = KRgbRed;
    TParaFormatMask mask;
    mask.SetAttrib( EAttFillColor );
    _LIT( KText, "abcd" );
    richtext->InsertL( 0, KText );
    TInt paraLen;   // Length of paragraph
    TInt fiChPos;   // First character position of paragraph
    // Get the length of the first paragraph
    fiChPos = richtext->CharPosOfParagraph( paraLen, 0 );
    richtext->ApplyParaFormatL( pf, mask, fiChPos, paraLen );
    CleanupStack::Pop(); // pf
    // Applying different background color for the next paragraph
    richtext->AppendParagraphL();
    CParaFormat* pf1 = new ( ELeave ) CParaFormat;
    CleanupStack::PushL( pf1 );
    pf1->iFillColor = KRgbBlue;
    TParaFormatMask mask1;
    mask1.SetAttrib( EAttFillColor );
    // Insert text in the second paragraph after the first one
    // paraLen has the value of the length of the first paragraph
    _LIT(KText1,"efgh");
    richtext->InsertL ( paraLen, KText1 );
    // Get the length of the second paragraph
    fiChPos=richtext->CharPosOfParagraph( paraLen, 1 );
    richtext->ApplyParaFormatL( pf1, mask1, fiChPos, paraLen );
    CleanupStack::Pop(); // pf1
        iEditor->ActivateL();

This page was last modified on 14 June 2012, at 09:23.
57 page views in the last 30 days.
×