How to change font colour?

Login to reply to this topic.
Thu, 2006-03-16 03:03
Joined: 2006-01-18
Forum posts: 114
i have rich text editor in my application. But the text color is green. Is there any way to change the color to black?

Grin

Thu, 2006-03-16 05:59
Joined: 2005-07-06
Forum posts: 53
Re: How to change font colour?
   TCharFormat     charFormat;
   TCharFormatMask charFormatMask;
   charFormatMask.SetAttrib(EAttColor);
   charFormat.iFontPresentation.iTextColor = KRgbBlack;
   charFormat.iFontSpec = LatinBold12()->FontSpecInTwips();
   charFormatMask.SetAll();

        ....

        iFormFieldId->ApplyCharFormatL(charFormat, charFormatMask);
Thu, 2006-03-16 09:15
Joined: 2006-01-18
Forum posts: 114
Re: How to change font colour?
This might be stupid question, but i don't know where to put that code.

This is my rich text editor header file:


#ifndef SYPHERQUERYRICHTEXTEDITOR_H
#define SYPHERQUERYRICHTEXTEDITOR_H

// INCLUDES

// System includes
#include <eikrted.h> // CCEikRichTextEditor
#include <txtfrmat.h> // TCharFormatMask


// CLASS DECLARATION

/**
*
* @class   CRichTextEditorRichTextEditor RichTextEditorContainer.h
* @brief   This is the rich text editor class for a Rich Text Editor example based on the
* standard Symbian OS architecture.
*
* Copyright (c) EMCC Software Ltd 2003
* @version   1.0
*
*/
class CSypherQueryRichTextEditor : public CEikRichTextEditor
        {
public: // Constructors and destructor

        static CSypherQueryRichTextEditor* NewL();
        static CSypherQueryRichTextEditor* NewLC();

private: // Constructor

        void ConstructL();

public: // from CoeControl

        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);

public: // members

        void SetUnderlineOn (TBool aOn);
        void SetBoldOn (TBool aOn);
        void AddCarriageReturnL ();
        void AddTextL (const TDesC& aText);
        void DisplayStartOfHelpTextL();
       


private: //data

        TCharFormatMask iCharFormatMask;  // current formatting, e.g bold etc
        TCharFormat iCharFormat; // current formatting, e.g bold etc

        };

#endif   // #ifndef SYPHERQUERYRICHTEXTEDITOR_H

// End of File
Thu, 2006-03-16 10:52
Joined: 2004-05-24
Forum posts: 15
Re: How to change font colour?
You have posted the header here. I beleive you would also have a cpp file for it in which you would write code for all the functions declared here.

You can write the code of TCharFormat in the constructl function. This would make all your editors of the formatting that you have done in contructl by default.

good luck
Fri, 2006-03-17 09:24
Joined: 2006-01-18
Forum posts: 114
Re: How to change font colour?
I include the code in constructL but got error.

My .cpp file

void CSypherQueryRichTextEditor::ConstructL()
        {
        TResourceReader reader;
       
       
iCharFormatMask.SetAttrib(EAttColor);
iCharFormat.iFontPresentation.iTextColor = KRgbBlack;
iCharFormat.iFontSpec = LatinBold12()->FontSpecInTwips();
iCharFormatMask.SetAll();

       
        iCoeEnv->CreateResourceReaderLC(reader, R_SYPHERQUERY_UPDATES_TEXT_EDITOR);
        ConstructFromResourceL(reader);
        CleanupStack::PopAndDestroy(); // reader
        SetFocus(ETrue);
        }


error

"SypherQueryRichTextEditor.cpp":     Call to undefined function 'LatinBold12' in function CSypherQueryRichTextEditor::ConstructL() at line 34
"SypherQueryRichTextEditor.cpp":     Pointer to structure required on left side of -> or ->* in function CSypherQueryRichTextEditor::ConstructL() at line 34


dunno what's wrong Huh
  • Login to reply to this topic.