Nokia N97 SDK
Example Applications Guide

CRTEContainer Class Reference

#include <RichTextEditorContainer.h>

Inheritance diagram for CRTEContainer:

List of all members.

Detailed Description

CRTEContainer container control class.

Definition at line 32 of file RichTextEditorContainer.h.


Public Member Functions

void  ConstructL (const TRect &aRect)
  ~CRTEContainer ()
void  SetAlignment (CParaFormat::TAlignment)
void  SetSelectionL (TInt, TInt)
  Select an area of text.
void  SetCharacterBIUAttribL (CEikGlobalTextEditor::TFontStyleFlags)
  Swicht on/off the Bold/Italic/Underline attributes.
void  SetFont (const CFont *)
  Change the text's font.
void  Strike ()
void  SetColor (TRgb)
void  IntroL ()
  Demonstrate the how program use some Richtext feature.
void  DemoL ()

Private Member Functions

void  Prepare ()
  Prepare the Richtext Editor, set the Editor flags.
void  SetupL ()
  Apply the final settings after the Editor is activated.
void  PrepareBitmapL ()
  Append Bitmap to iBitmap Array.
void  InsertMyPictureL (TInt aPos)
  Call Richtext's InsertL() with the CPicture.
void  Echo (TInt)
  Echo the last engine operation to the status line.
void  SizeChanged ()
TInt  CountComponentControls () const
CCoeControl *  ComponentControl (TInt aIndex) const
void  Draw (const TRect &aRect) const
TKeyResponse  OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)

Private Attributes

CEikRichTextEditor *  iRtEd
CArrayFixFlat< CFbsBitmap * > *  iBitmap
CEikLabel *  iStatusLine
TBool  iStrike


Constructor & Destructor Documentation

CRTEContainer::~CRTEContainer (   ) 
 

Destructor.

Definition at line 227 of file RichTextEditorContainer.cpp.

References iBitmap, iRtEd, and iStatusLine.

00228     {
00229     if(iRtEd)
00230                 delete iRtEd;
00231         
00232         if(iStatusLine)
00233                 delete iStatusLine;
00234                 
00235         // Delete each image, which have reference in the Array
00236         for(int i=0;i<iBitmap->Count();i++)
00237                 {
00238                 if(iBitmap->At(i))
00239                         delete iBitmap->At(i);
00240                 }
00241         // Free the Array
00242         if(iBitmap)
00243                 delete iBitmap;
00244     }


Member Function Documentation

void CRTEContainer::ConstructL (  const TRect &  aRect  ) 
 

EPOC default constructor.

Parameters:
aRect  Frame rectangle for container.

Definition at line 199 of file RichTextEditorContainer.cpp.

References iBitmap, IntroL(), iRtEd, iStatusLine, Prepare(), PrepareBitmapL(), and SetupL().

Referenced by CRTEAppUi::ConstructL().

00200     {
00201         CreateWindowL();
00202 
00203         iBitmap = new (ELeave) CArrayFixFlat<CFbsBitmap *>(2); // DemoL() show two image        
00204         iRtEd = new (ELeave) CEikRichTextEditor;
00205         
00206         iStatusLine = new (ELeave) CEikLabel;
00207         iStatusLine->SetAlignment(EHCenterVCenter);
00208 
00209         Prepare();
00210         PrepareBitmapL();
00211         
00212         iRtEd->ConstructL(this,0,0,0);
00213         iRtEd->SetFocus(ETrue);
00214         
00215         SetRect(aRect);
00216 
00217         IntroL();
00218         ActivateL();
00219         SetupL();
00220     }

void CRTEContainer::SetAlignment (  CParaFormat::TAlignment   ) 
 

Toggle -left-center-right- alignment within the actual paragraph

Definition at line 338 of file RichTextEditorContainer.cpp.

References Echo(), and iRtEd.

Referenced by CRTEAppUi::HandleCommandL(), and IntroL().

00339         {
00340         CParaFormat     paraFormat;
00341         TParaFormatMask paraFormatMask;
00342 
00343         paraFormatMask.SetAttrib(EAttAlignment);    // set the mask
00344         paraFormat.iHorizontalAlignment = aAlignment;
00345 
00346         iRtEd->ApplyParaFormatL(&paraFormat, paraFormatMask);
00347         
00348         Echo(R_TYPE_DIALOG_TBUF_INDICATOR_ALIGNMENT);
00349         }

void CRTEContainer::Strike (   ) 
 

Toggle between strikethrough or not strikethrough text

Definition at line 430 of file RichTextEditorContainer.cpp.

References Echo(), iRtEd, and iStrike.

Referenced by CRTEAppUi::HandleCommandL().

00431         {
00432     TCharFormat charFormat;
00433         TCharFormatMask charFormatMask;
00434 
00435         iStrike=!iStrike;
00436         charFormat.iFontPresentation.iStrikethrough=iStrike?EStrikethroughOn:EStrikethroughOff;
00437     charFormatMask.SetAttrib(EAttFontStrikethrough);
00438         iRtEd->ApplyCharFormatL(charFormat, charFormatMask);
00439 
00440         if(iStrike)
00441                 {
00442                 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_STRIKE_ON);
00443                 }
00444         else
00445                 {
00446                 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_STRIKE_OFF);
00447                 }
00448         }

void CRTEContainer::SetColor (  TRgb   ) 
 

Change the text's color

Definition at line 455 of file RichTextEditorContainer.cpp.

References iRtEd.

Referenced by DemoL(), and CRTEAppUi::HandleCommandL().

00456         {
00457         TCharFormat charFormat;
00458         TCharFormatMask charFormatMask;
00459 
00460         charFormat.iFontPresentation.iTextColor = aColor;
00461         charFormatMask.SetAttrib(EAttColor);
00462         iRtEd->ApplyCharFormatL(charFormat, charFormatMask);
00463         
00464 //      iRtEd->SetBackgroundColorL(aColor); 
00465 //  It is possible to change the background color - if foreground and background 
00466 //  color is same, the text became invisible.
00467         }

void CRTEContainer::DemoL (   ) 
 

Create Demo Content

Definition at line 145 of file RichTextEditorContainer.cpp.

References InsertMyPictureL(), iRtEd, SetColor(), and SetSelectionL().

Referenced by CRTEAppUi::HandleCommandL().

00146         {
00147         iRtEd->SetCursorPosL(0,EFalse);
00148         // Set the Demo text to Richtext Editor
00149         TBuf<KBufSize> Demobuf;
00150         CEikonEnv::Static()->ReadResource(Demobuf, R_TYPE_II_DIALOG_TBUF_DEMO_TEXT);
00151         iRtEd->SetTextL(&Demobuf);
00152         
00153         // Insert a Bipmaps to Richtext 
00154         InsertMyPictureL(KLeftImagePositionInTheText);
00155         InsertMyPictureL(KRightImagePositionInTheText);
00156         
00157         //// To Compare the '\f' to EParagraphDelimiter change the comment status of the two following lines
00158         //iRtEd->RichText()->InsertL( KEndofCenterFormat , CEditableText::EParagraphDelimiter);
00159         _LIT(KFormat, "\f");
00160         iRtEd->RichText()->InsertL( KEndofCenterFormat , KFormat);
00161 
00162         // Basic Text Formatting border by EParagraphDelimiter, same as in Forum Nokia's Type - Example
00163         iRtEd->RichText()->InsertL( KLeftImagePositionInTheText , CEditableText::EParagraphDelimiter);
00164         
00165         // Do some color change
00166         SetSelectionL(KLeftImagePositionInTheText, KRightImagePositionInTheText);
00167         SetColor(KRgbRed);
00168         SetSelectionL(KLeftNokia, KRightNokia);
00169         SetColor(KRgbBlue);
00170         
00171         //set newline end of document
00172         iRtEd->RichText()->InsertL(iRtEd->Text()->DocumentLength() , CEditableText::ELineBreak);
00173         
00174         // Set the cursor end of the document
00175         iRtEd->SetCursorPosL(iRtEd->Text()->DocumentLength(), EFalse);
00176         }

void CRTEContainer::SizeChanged (   )  [private]
 

From CoeControl,SizeChanged.

Definition at line 251 of file RichTextEditorContainer.cpp.

Referenced by SetupL().

00252     {
00253         TRect rect = Rect();
00254         TInt StatusLineHeight = iStatusLine->Font()->HeightInPixels()+6;
00255         iStatusLine->SetExtent(TPoint(0, 0),TSize(rect.Width(), StatusLineHeight));
00256         
00257         #ifdef __SERIES60_3X__
00258         TRect ScrollBarRect = iRtEd->ScrollBarFrame()->VerticalScrollBar()->Rect();
00259         //In 3rd edition CEikRichTextEditor draw the view for the whole rect and
00260         //the scrollbar doesn't show. That is a reason why CEikRichTextEditor Width() is
00261         //rect.Width()-ScrollBarRect.Width()
00262         iRtEd->SetExtent(TPoint(0,StatusLineHeight), 
00263                 TSize(rect.Width()-ScrollBarRect.Width(), rect.Height()-StatusLineHeight));
00264         #else
00265     iRtEd->SetExtent(TPoint(0,StatusLineHeight), 
00266         TSize(rect.Width(), rect.Height()-StatusLineHeight));
00267     #endif
00268     }

TInt CRTEContainer::CountComponentControls (   )  const [private]
 

From CoeControl,CountComponentControls.

Definition at line 274 of file RichTextEditorContainer.cpp.

00275     {
00276     return 2; // return number of controls inside this container
00277     }

CCoeControl * CRTEContainer::ComponentControl (  TInt  aIndex  )  const [private]
 

From CCoeControl,ComponentControl.

Definition at line 283 of file RichTextEditorContainer.cpp.

References iRtEd, and iStatusLine.

00284     {
00285     switch ( aIndex )
00286         {
00287         case 0:
00288                         return iRtEd;
00289                 case 1:
00290                         return iStatusLine;
00291         default:
00292             return NULL;
00293         }
00294     }

void CRTEContainer::Draw (  const TRect &  aRect  )  const [private]
 

From CCoeControl,Draw.

Definition at line 300 of file RichTextEditorContainer.cpp.

00301     {
00302     CWindowGc& gc = SystemGc();
00303     gc.SetPenStyle(CGraphicsContext::ENullPen);
00304     gc.SetBrushColor(KRgbWhite);
00305     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00306     gc.DrawRect(aRect);
00307     }

TKeyResponse CRTEContainer::OfferKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
)  [private]
 

From CCoeControl,OfferKeyEventL.

Definition at line 314 of file RichTextEditorContainer.cpp.

References iRtEd.

00315         {
00316         if (iRtEd->IsFocused())
00317                 {
00318                 return iRtEd->OfferKeyEventL(aKeyEvent, aType); 
00319                 }
00320         else
00321                 {
00322                 return EKeyWasNotConsumed;
00323                 }
00324         }


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top