meetingrequest/mrgui/mrfieldbuildercommon/inc/cesmrrichtextviewer.h
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
child 16 b5fbb9b25d57
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 *  Description : CEikRichTextEditor based Rich Text viewer
    14 *  Description : CEikRichTextEditor based Rich Text viewer
    15 *  Version     : %version: tr1sido#4.1.4 %
    15 *  Version     : %version: e002sa32#19 %
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #ifndef CESMRRICHTEXTVIEWER_H
    19 #ifndef CESMRRICHTEXTVIEWER_H
    20 #define CESMRRICHTEXTVIEWER_H
    20 #define CESMRRICHTEXTVIEWER_H
    21 
    21 
    22 #include <eikrted.h>
    22 #include <eikrted.h>
    23 #include <cntitem.h>
    23 #include <cntitem.h>
    24 #include <eikcmobs.h>
    24 #include <eikcmobs.h>
    25 #include <aknlongtapdetector.h>
       
    26 
    25 
    27 #include "resmrstatic.h"
    26 #include "resmrstatic.h"
       
    27 #include "mmrcontactmenuobserver.h"
    28 
    28 
    29 class CESMRRichTextLink;
    29 class CESMRRichTextLink;
    30 class CESMRLayoutManager;
       
    31 class MESMRFieldEventQueue;
    30 class MESMRFieldEventQueue;
    32 
    31 
    33 // SCROLLING_MOD: List observer forward declaraion
    32 // SCROLLING_MOD: List observer forward declaraion
    34 class MESMRListObserver;
    33 class MESMRListObserver;
       
    34 class MMRFieldScrollObserver;
    35 
    35 
    36 /*
    36 /*
    37  * Pure virtual link selection observer.
    37  * Pure virtual link selection observer.
    38  */
    38  */
    39 class MESMRRichTextObserver
    39 class MESMRRichTextObserver
    51 
    51 
    52 /*
    52 /*
    53  * CEikRichTextEditor based Rich Text viewer.
    53  * CEikRichTextEditor based Rich Text viewer.
    54  */
    54  */
    55 NONSHARABLE_CLASS( CESMRRichTextViewer ) : public CEikRichTextEditor,
    55 NONSHARABLE_CLASS( CESMRRichTextViewer ) : public CEikRichTextEditor,
    56                                            public MEikCommandObserver, 
    56                                            public MEikCommandObserver,
    57                                            public MAknLongTapDetectorCallBack
    57                                            public MMRContactMenuObserver
    58     {
    58     {
    59 public:
    59 public:
    60     /*
    60     /*
    61      * Two-phase constructor.
    61      * Two-phase constructor.
    62      * @param aParent if aParent is NULL, 
    62      * @param aParent if aParent is NULL,
    63      * 				  CEikRichTextEditor is constucted as 
    63      * 				  CEikRichTextEditor is constucted as
    64      * 				  window owning control.
    64      * 				  window owning control.
    65      * @return Created object
    65      * @return Created object
    66      */
    66      */
    67     IMPORT_C static CESMRRichTextViewer* NewL(
    67     IMPORT_C static CESMRRichTextViewer* NewL(
    68             const CCoeControl* aParent = NULL);
    68             const CCoeControl* aParent = NULL);
    74 
    74 
    75     // From CCoeControl
    75     // From CCoeControl
    76     IMPORT_C void PositionChanged( );
    76     IMPORT_C void PositionChanged( );
    77     IMPORT_C void FocusChanged( TDrawNow aDrawNow );
    77     IMPORT_C void FocusChanged( TDrawNow aDrawNow );
    78     IMPORT_C TKeyResponse OfferKeyEventL(
    78     IMPORT_C TKeyResponse OfferKeyEventL(
    79     		const TKeyEvent &aKeyEvent, 
    79     		const TKeyEvent &aKeyEvent,
    80     		TEventCode aType );
    80     		TEventCode aType );
    81 
       
    82     IMPORT_C void SetMargins( TInt sMargin );
    81     IMPORT_C void SetMargins( TInt sMargin );
    83 
    82 
    84     IMPORT_C void SetFontL( 
    83     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
    85     		const CFont* aFont, 
    84 
    86     		CESMRLayoutManager* aLayout = NULL );
    85     /*
       
    86      * Sets the given font for the rich text component. Also
       
    87      * sets the default main area color. Changes take effect
       
    88      * after AppliyLayoutChanges is called.
       
    89      *
       
    90      * @param aFont, the font to be set for the rich text component.
       
    91      */
       
    92     IMPORT_C void SetFontL( const CFont* aFont );
    87 
    93 
    88     /*
    94     /*
    89      * Sets CEikRichTextEditor's text and searches text for emails,
    95      * Sets CEikRichTextEditor's text and searches text for emails,
    90      * phone numbers and urls if aSearchLinks is set to ETrue.
    96      * phone numbers and urls if aSearchLinks is set to ETrue.
    91      *
    97      *
   103     /*
   109     /*
   104      * Adds link to text.
   110      * Adds link to text.
   105      * @param aLink link to be added
   111      * @param aLink link to be added
   106      */
   112      */
   107     IMPORT_C void AddLinkL(CESMRRichTextLink* aLink );
   113     IMPORT_C void AddLinkL(CESMRRichTextLink* aLink );
   108     
   114 
   109     /**
   115     /**
   110      * Inserts link to text.
   116      * Inserts link to text.
   111      * @param aLink link to be added
   117      * @param aLink link to be added
   112      * @param aPosition position where link is added
   118      * @param aPosition position where link is added
   113      */
   119      */
   121     /*
   127     /*
   122      * Returns text for selected link from underlying CEikRichTextViewer.
   128      * Returns text for selected link from underlying CEikRichTextViewer.
   123      *
   129      *
   124      * @param aLink link
   130      * @param aLink link
   125      */
   131      */
   126     IMPORT_C HBufC* GetLinkTextL( const CESMRRichTextLink& aLink ) const;
   132     IMPORT_C HBufC* GetLinkTextLC( const CESMRRichTextLink& aLink ) const;
   127 
   133 
   128     /*
   134     /*
   129      * Returns pointer to new CContactItem constructed from aLink.
   135      * Returns pointer to new CContactItem constructed from aLink.
   130      * Function uses CESMRRichTextLink::Value to create contact
   136      * Function uses CESMRRichTextLink::Value to create contact
   131      * with CESMRRichTextLink::Type information.
   137      * with CESMRRichTextLink::Type information.
   132      *
   138      *
   133      * @param aLink link
   139      * @param aLink link
   134      */
   140      */
   135     IMPORT_C CContactItem* CreateContactItemL( const CESMRRichTextLink& aLink );
   141     IMPORT_C CContactItem* CreateContactItemL( const CESMRRichTextLink& aLink );
   136 
   142 
   137  
       
   138     /*
   143     /*
   139     * Method for cesmrviewerdescriptionfield to set the list observer
   144     * Method for cesmrviewerdescriptionfield to set the list observer
   140     *
   145     *
   141     * @param aObserver observer that should be notified
   146     * @param aObserver observer that should be notified
   142     */
   147     */
   143     IMPORT_C void SetListObserver( MESMRListObserver* aObserver );
   148     IMPORT_C void SetListObserver( MESMRListObserver* aObserver );
   144     
   149 
   145     /**
   150     /**
   146      * Returns height of one row.
   151      * Returns height of one row.
   147      *
   152      *
   148      * @return row's height
   153      * @return row's height
   149      */
   154      */
   153      *
   158      *
   154      * @return line count
   159      * @return line count
   155      */
   160      */
   156     IMPORT_C TInt LineCount();
   161     IMPORT_C TInt LineCount();
   157     /**
   162     /**
   158      * Returns line number of currenly 
   163      * Returns line number of currenly
   159      * focused row starting from one.
   164      * focused row starting from one.
   160      * 
   165      *
   161      * @return row's height
   166      * @return row's height
   162      */
   167      */
   163     IMPORT_C TInt CurrentLineNumber();
   168     IMPORT_C TInt CurrentLineNumber();
   164 
   169 
   165     /**
   170     /**
   167      * @param aStatus Enables or disables action menu
   172      * @param aStatus Enables or disables action menu
   168      */
   173      */
   169     IMPORT_C void SetActionMenuStatus( TBool aStatus );
   174     IMPORT_C void SetActionMenuStatus( TBool aStatus );
   170 
   175 
   171     /**
   176     /**
   172      * Copies currently selected richtext link associated with 
   177      * Copies currently selected richtext link associated with
   173      * action menu to the clipboard
   178      * action menu to the clipboard
   174      */
   179      */
   175     IMPORT_C void CopyCurrentLinkToClipBoardL() const;
   180     IMPORT_C void CopyCurrentLinkToClipBoardL() const;
   176 
   181 
   177     /**
   182     /**
   178      * Copies currently link value to clipboard 
   183      * convenience method to reset TLS static contactactionmenuhandler
   179      * action menu to the clipboard
   184      * for classes that only have access to richtextviewer.
   180      */
       
   181     IMPORT_C void CopyCurrentLinkValueToClipBoardL() const;
       
   182 
       
   183     /**
       
   184      * convenience method to reset TLS static contactactionmenuhandler 
       
   185      * for classes that only have access to richtextviewer. 
       
   186      * Needed for richtextviewer fields when they lose focus.
   185      * Needed for richtextviewer fields when they lose focus.
   187      */
   186      */
   188     IMPORT_C void ResetActionMenuL() const;
   187     IMPORT_C void ResetActionMenuL() const;
   189 
   188 
   190     /**
   189     /**
   197     /**
   196     /**
   198      * Selects current link.
   197      * Selects current link.
   199      * @return ETrue if link selected
   198      * @return ETrue if link selected
   200      */
   199      */
   201     IMPORT_C TBool LinkSelectedL();
   200     IMPORT_C TBool LinkSelectedL();
       
   201 
       
   202     /**
       
   203      * Handles long tap event in rich text viewer.
       
   204      * @param aPosition position of long tap event.
       
   205      */
       
   206     IMPORT_C void HandleLongtapEventL( TPoint& aPosition );
       
   207 
       
   208     /*
       
   209      * Sets the given line spacing for the rich text component.
       
   210      * Changes take effect after AppliyLayoutChanges is called.
       
   211      *
       
   212      * @param aLineSpacingInTwips, the line spacing to be used.
       
   213      */
       
   214     IMPORT_C void SetLineSpacingL( TInt aLineSpacingInTwips );
       
   215 
       
   216     /*
       
   217      * Applies the layout changes to the rich text component.
       
   218      */
       
   219     IMPORT_C void ApplyLayoutChangesL();
   202     
   220     
       
   221     /*
       
   222      * Set selected link according to the index in the array.
       
   223      * @param aLinkIndex the index of link need to be selected.
       
   224      */
       
   225     IMPORT_C void SetFocusLink( TInt aLinkIndex );
       
   226 
       
   227     /*
       
   228      * Get the index of selected link in the array.
       
   229      * @return The index of selected link in the array.
       
   230      */
       
   231     IMPORT_C TInt GetFocusLink( ) const;
       
   232 
   203 protected: // From MEikCommandObserver
   233 protected: // From MEikCommandObserver
   204     
   234 
   205     /**
   235     /**
   206      * Process commands from contact menu handler.
   236      * Process commands from contact menu handler.
   207      * Forwards commands to event observer. 
   237      * Forwards commands to event observer.
   208      */
   238      */
   209     void ProcessCommandL( TInt aCommandId );
   239     void ProcessCommandL( TInt aCommandId );
   210 
   240 
   211 protected: // From MAknLongTapDetectorCallBack
       
   212     virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, 
       
   213                                       const TPoint& aPenEventScreenLocation );
       
   214     
       
   215 protected: // From CEikEdwin
   241 protected: // From CEikEdwin
   216     /**
   242     /**
   217      * Sets the control as ready to be drawn.
   243      * Sets the control as ready to be drawn.
   218      */
   244      */
   219     void ActivateL();
   245     void ActivateL();
   220 
   246 
   221 protected: // From CCoeControl
   247 protected: // From MMRContactMenuObserver
   222     virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   248 
   223     
   249     void ContactActionQueryComplete();
       
   250 
   224 private:
   251 private:
   225     /*
   252     /*
   226      * Private constuctor.
   253      * Private constuctor.
   227      */
   254      */
   228     CESMRRichTextViewer( );
   255     CESMRRichTextViewer( );
   229 
   256 
   230     /*
   257     /*
   231      * Two-phase constructor.
   258      * Two-phase constructor.
   232      * @param aParent if aParent is NULL, CEikRichTextEditor 
   259      * @param aParent if aParent is NULL, CEikRichTextEditor
   233      * 				  is constucted as window owning control.
   260      * 				  is constucted as window owning control.
   234      */
   261      */
   235     void ConstructL(const CCoeControl* aParent );
   262     void ConstructL(const CCoeControl* aParent );
   236 
   263 
   237     /*
   264     /*
   238      * CCoeControl::Draw is overridden.
       
   239      */
       
   240     void Draw( const TRect& aRect ) const;
       
   241 
       
   242     /*
       
   243      * Draws right-click icon.
       
   244      * @param aLink link to which draw icon
       
   245      */
       
   246     void DrawRightClickIconL(const CESMRRichTextLink& aLink) const;
       
   247 
       
   248     /*
       
   249      * Highlights link in CEikRichTextEditor.
   265      * Highlights link in CEikRichTextEditor.
   250      *
   266      *
   251      * @param aLink link to be highlighted
   267      * @param aLink link to be highlighted
   252      */
   268      */
   253     void HighlightLink(const CESMRRichTextLink& aLink );
   269     void HighlightLinkL(const CESMRRichTextLink& aLink );
   254 
   270 
   255     /*
   271     /*
   256      * Private internal function which searches for emails,
   272      * Private internal function which searches for emails,
   257      * phone numbers and urls from given text using CFindItemEngine.
   273      * phone numbers and urls from given text using CFindItemEngine.
   258      *
   274      *
   259      * @param aText text which is shown in CEikRichTextEditor
   275      * @param aText text which is shown in CEikRichTextEditor
   260      */
   276      */
   261     void SearchLinksL(const TDesC& aText );
   277     void SearchLinksL(const TDesC& aText );
   262 
   278 
   263     void ScrollViewL( 
   279     TInt FindTextLinkBetweenNextScrollArea(
   264     		TInt aNumberOfRows, 
   280     		TInt aStartRow,
       
   281     		TInt aEndRow,
   265     		TCursorPosition::TMovementType aDirection);
   282     		TCursorPosition::TMovementType aDirection);
   266     TInt FindTextLinkBetweenNextScrollArea(
   283 
   267     		TInt aStartRow,                  
       
   268     		TInt aEndRow,                               
       
   269     		TCursorPosition::TMovementType aDirection);
       
   270 
       
   271     TBool SetHighLightToNextLinkL( TCursorPosition::TMovementType aDirection,
       
   272                                    TInt aStartRow,
       
   273                                    TInt aEndRow);
       
   274     TInt ValidLinkForFocusing(	TInt aIndex,
   284     TInt ValidLinkForFocusing(	TInt aIndex,
   275                                 TCursorPosition::TMovementType aDirection,
   285                                 TCursorPosition::TMovementType aDirection,
   276                                 TInt aStartRow,
   286                                 TInt aStartRow,
   277                                 TInt aEndRow);
   287                                 TInt aEndRow);
   278 
   288 
   279     void SetFontColorL( TBool aFocused = EFalse );
       
   280 
       
   281     void SetValueL( const CESMRRichTextLink& aLink );
   289     void SetValueL( const CESMRRichTextLink& aLink );
   282 
   290 
       
   291     void ShowContextMenuL();
       
   292 
       
   293     void GetLinkAreaL( TRegion& aRegion,
       
   294                        const CESMRRichTextLink& aLink ) const;
       
   295 
       
   296     void ChangeMiddleSoftkeyL( const CESMRRichTextLink& aLink );
       
   297 
       
   298     void UpdateViewL( const TKeyEvent &aKeyEvent );
       
   299 
   283 private: // Data
   300 private: // Data
   284 	/// Own:
   301 
   285     TInt iCurrentLinkIndex;
   302 	/// Own: Array of hyperlinks in viewer
   286     /// Own:
       
   287     RPointerArray<CESMRRichTextLink> iLinkList;
   303     RPointerArray<CESMRRichTextLink> iLinkList;
   288     /// Ref:
   304     /// Ref:
   289     MESMRRichTextObserver* iLinkObserver;
   305     MESMRRichTextObserver* iLinkObserver;
   290     /// Own:
   306     /// Own:
   291     RESMRStatic iESMRStatic;
   307     RESMRStatic iESMRStatic;
   292     /// Own:
       
   293     CFbsBitmap* iActionMenuIcon;
       
   294     /// Own:
       
   295     CFbsBitmap* iActionMenuIconMask;
       
   296     /// Ref:
   308     /// Ref:
   297     MESMRListObserver* iObserver;
   309     MESMRListObserver* iObserver;
   298     /// Own:
       
   299     TInt iNumberOfLines;
       
   300     /// Own:
   310     /// Own:
   301     TInt iApproximatelyRowHeight;
   311     TInt iApproximatelyRowHeight;
   302     /// Ref: pointer to font
   312     /// Ref: pointer to font
   303     const CFont* iFont;
   313     const CFont* iFont;
   304     /// Ref: Pointer to layout manager
       
   305     CESMRLayoutManager* iLayout;
       
   306     /// Ref: Contact Menu handler
   314     /// Ref: Contact Menu handler
   307     CESMRContactMenuHandler* iCntMenuHdlr;
   315     CESMRContactMenuHandler* iCntMenuHdlr;
   308     /// Ref: Pointer to event queue
   316     /// Ref: Pointer to event queue
   309     MESMRFieldEventQueue* iEventQueue;
   317     MESMRFieldEventQueue* iEventQueue;
   310     /// Own: Flag for action menu status
   318     /// Own: Rich text link format
   311     TBool iActionMenuStatus;
   319     TCharFormat iRichTextLinkFormat;
       
   320     /// Own: Rich text link format mask
       
   321     TCharFormatMask iRichTextLinkFormatMask;
   312     /// Own:
   322     /// Own:
   313     TCharFormat iFormat;
   323     TBool iOpenActionMenu;
   314     /// Own:
   324     // Own: Paragraph formatter
   315     TCharFormatMask iFormatMask;
   325     CParaFormat* iParaFormat;
   316     // Own:    
   326     // Own: Paragraph formatter mask
   317     CAknLongTapDetector* iLongTapDetector;
   327     TParaFormatMask iParaFormatMask;
   318     // Indicates is action menu opened
   328     // Own: Character formatter
   319     TBool iActionMenuOpen;
   329     TCharFormat iCharFormat;
       
   330     // Own: Character formatter mask
       
   331     TCharFormatMask iCharFormatMask;
   320     };
   332     };
   321 
   333 
   322 #endif /*CESMRRICHTEXTVIEWER_H*/
   334 #endif /*CESMRRICHTEXTVIEWER_H*/