diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/richtexteditorrte_8cpp_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/richtexteditorrte_8cpp_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,136 @@ + + +
+ +00001 /* +00002 * ============================================================================ +00003 * Name : CRichTextEditorRTE from CRichTextEditorRTE.h +00004 * Part of : Thread +00005 * Created : 04.02.2005 by Forum Nokia +00006 * Version : 1.0 +00007 * Copyright: Nokia Corporation +00008 * ============================================================================ +00009 */ +00010 +00011 // INCLUDES +00012 #include "RichTextEditorRTE.h" +00013 #include <barsread.h> // TResourceReader +00014 #include <thread.rsg> // resources +00015 #include <eikrted.h> // CEikRichTextEditor +00016 #include <txtrich.h> // CRichText +00017 +00018 // Standard EPOC 2nd phase constructor +00019 void CRichTextEditorRTE::ConstructL(const CCoeControl& aView) +00020 { +00021 TResourceReader reader; +00022 // Construct RichTextEditor from resource +00023 iCoeEnv->CreateResourceReaderLC(reader, R_RICHTEXTEDITOR_RICH_TEXT_EDITOR); +00024 SetContainerWindowL(aView); +00025 ConstructFromResourceL(reader); +00026 CleanupStack::PopAndDestroy(); // reader +00027 // Sets that the control has keyboard focus +00028 SetFocus(ETrue); +00029 } +00030 +00031 // ---------------------------------------------------------------------------- +00032 // CRichTextEditorRTE::CRichTextEditorRTE(void) +00033 // +00034 // constructor +00035 // ---------------------------------------------------------------------------- +00036 CRichTextEditorRTE::CRichTextEditorRTE(void) +00037 { +00038 } +00039 +00040 // ---------------------------------------------------------------------------- +00041 // CRichTextEditorRTE::AddCarriageReturnL() +00042 // +00043 // Insert one line break at the end of the text. +00044 // ---------------------------------------------------------------------------- +00045 void CRichTextEditorRTE::AddCarriageReturnL() +00046 { +00047 CRichText* richText = RichText(); +00048 richText->InsertL(richText->DocumentLength(), CEditableText::ELineBreak); +00049 } +00050 +00051 // ---------------------------------------------------------------------------- +00052 // CRichTextEditorRTE::AddTextL(const TDesC& aText) +00053 // +00054 // Draws text using black color. +00055 // ---------------------------------------------------------------------------- +00056 void CRichTextEditorRTE::AddTextL(const TDesC& aText) +00057 { +00058 CRichText* text = RichText(); +00059 TInt textSize = text->DocumentLength(); +00060 +00061 // Interested in color +00062 iCharacterFormatMask.SetAttrib(EAttColor); +00063 // Set it to Black +00064 iCharacterFormat.iFontPresentation.iTextColor = KRgbBlack; +00065 text->InsertL (textSize, aText); +00066 // Apply formatting +00067 text->ApplyCharFormatL(iCharacterFormat, iCharacterFormatMask,textSize,aText.Length()); +00068 AddCarriageReturnL(); +00069 HandleTextChangedL(); +00070 +00071 //Keep displaying the bottom of the screen +00072 MoveCursorL (TCursorPosition::EFPageDown, EFalse); +00073 } +00074 +00075 CRichTextEditorRTE* CRichTextEditorRTE::NewL(const CCoeControl& aView) +00076 { +00077 CRichTextEditorRTE* self = CRichTextEditorRTE::NewLC(aView); +00078 CleanupStack::Pop(self); +00079 return self; +00080 } +00081 +00082 CRichTextEditorRTE* CRichTextEditorRTE::NewLC(const CCoeControl& aView) +00083 { +00084 CRichTextEditorRTE* self = new (ELeave) CRichTextEditorRTE; +00085 CleanupStack::PushL(self); +00086 self->ConstructL(aView); +00087 return self; +00088 } +00089 +00090 // ---------------------------------------------------------------------------- +00091 // TKeyResponse CRichTextEditorRTE::OfferKeyEventL(const TKeyEvent& aKeyEvent, +00092 // TEventCode aType) +00093 // +00094 // Called by the framework whenever a key event occurs. Handles scrolling +00095 // events. +00096 // ---------------------------------------------------------------------------- +00097 TKeyResponse CRichTextEditorRTE::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) +00098 { +00099 if (aType == EEventKey) +00100 { +00101 if (aKeyEvent.iCode == EKeyDownArrow) +00102 { +00103 MoveCursorL (TCursorPosition::EFPageDown, EFalse); +00104 +00105 return EKeyWasConsumed; +00106 } +00107 else if (aKeyEvent.iCode == EKeyUpArrow) +00108 { +00109 MoveCursorL (TCursorPosition::EFPageUp, EFalse); +00110 +00111 return EKeyWasConsumed; +00112 } +00113 else +00114 { +00115 return CEikRichTextEditor::OfferKeyEventL(aKeyEvent, aType); +00116 } +00117 } +00118 +00119 return EKeyWasNotConsumed; +00120 } +