williamr@2: /* williamr@2: * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKRTED_H__) williamr@2: #define __EIKRTED_H__ williamr@2: williamr@2: #if !defined(__EIKGTED_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__APPARC_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__TXTMRTSR_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__GDI_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: class CRichText; williamr@2: class TResourceReader; williamr@2: class TPictureHeader; williamr@2: class CEikRubberBand; williamr@2: class CBufStore; williamr@2: class CStreamStore; williamr@2: class CApaDoor; williamr@2: class CEikParserManager; williamr@2: class MEikRichTextEditorParserObserver; williamr@2: class MParser; williamr@2: williamr@2: /** williamr@2: * Rich text editor. williamr@2: * williamr@2: * This is an edit window that supports rich text, including embedded objects williamr@2: * represented either by icons or glass doors. williamr@2: * williamr@2: * @since Symbian 5.0 williamr@2: */ williamr@2: class CEikRichTextEditor : public CEikGlobalTextEditor, williamr@2: public MApaEmbeddedDocObserver, williamr@2: public MRichTextStoreResolver, williamr@2: public MPictureFactory williamr@2: { williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Identifies how an embedded object should be represented. williamr@2: * williamr@2: * One of these values is specified when the object is inserted. williamr@2: */ williamr@2: enum TObjectFormat williamr@2: { williamr@2: /** The object is always represented by an icon */ williamr@2: EAlwaysIconic, williamr@2: williamr@2: /** williamr@2: * The object is represented by a glass door, if possible, or by icon, williamr@2: * if not. williamr@2: */ williamr@2: EGlassIfPossible williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Edit window attribute flags specific to the rich text editor. williamr@2: * williamr@2: * These may be specified during construction in addition to the values williamr@2: * contained in the @c TFlags enum in class @c CEikEdwin. williamr@2: */ williamr@2: enum // user flag williamr@2: { williamr@2: /** williamr@2: * All embedded objects are represented by icon rather than williamr@2: * glass doors. williamr@2: */ williamr@2: EShowAllPicturesAsIconic =0x00100000, williamr@2: williamr@2: /** williamr@2: * The editor has no text parsers. williamr@2: * williamr@2: * Text parsers are used to recognise and tag special text strings, williamr@2: * e.g. URLs. williamr@2: */ williamr@2: ENoTextParsers =0x00200000, williamr@2: williamr@2: /** williamr@2: * When pasting text into the editor, the text is williamr@2: * stripped of all formatting. williamr@2: * williamr@2: * @since 3.2 williamr@2: */ williamr@2: EPasteAsPlainText =0x00400000 williamr@2: }; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CEikRichTextEditor(); williamr@2: williamr@2: /** williamr@2: * C++ constructor. williamr@2: * williamr@2: * @param aBorder Border for the rich text editor. williamr@2: */ williamr@2: IMPORT_C CEikRichTextEditor(const TGulBorder& aBorder); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CEikRichTextEditor(); williamr@2: williamr@2: /** williamr@2: * By default Symbian 2nd phase constructor is private. williamr@2: * williamr@2: * Completes construction of the rich text editor. williamr@2: * williamr@2: * The editor's paragraph and character formatting are set to default williamr@2: * values, unless the @c CEikEdwin::EUserSuppliedText flag is specified williamr@2: * in @c aEdwinFlags. williamr@2: * williamr@2: * @param aParent If not NULL, the editor's parent control. williamr@2: * If NULL, the editor has no parent. williamr@2: * @param aNumberOfLines The number of lines visible in the editor. williamr@2: * This controls the editor's height. williamr@2: * @param aTextLimit The maximum number of characters that can be entered williamr@2: * into the editor. williamr@2: * @param aEdwinFlags Edit window attribute flags. williamr@2: * See @c CEikEdwin::TFlags(). williamr@2: * @param aFontControlFlags = EGulFontControlAll Flags that specify which williamr@2: * font-related controls should not appear in font dialogs launched williamr@2: * from the edit window. For instance @c EGulFontControlBold removes williamr@2: * the bold checkbox control. The default shows all. For possible williamr@2: * values, see @c gulftflg.hrh. williamr@2: * @param aFontNameFlags = EGulNoSymbolFonts The font flags. These control williamr@2: * whether symbol and monospace fonts should be displayed in font williamr@2: * dialogs launched from the edit window. For possible values, see williamr@2: * @c gulftflg.hrh. williamr@2: */ williamr@2: IMPORT_C void ConstructL(const CCoeControl* aParent, williamr@2: TInt aNumberOfLines, williamr@2: TInt aTextLimit, williamr@2: TInt aEdwinFlags, williamr@2: TInt aFontControlFlags=EGulFontControlAll, williamr@2: TInt aFontNameFlags=EGulNoSymbolFonts); williamr@2: williamr@2: /** williamr@2: * Gets a pointer to the rich text object owned by the editor. williamr@2: * williamr@2: * @return Pointer to the rich text object. williamr@2: */ williamr@2: IMPORT_C CRichText* RichText() const; williamr@2: williamr@2: /** williamr@2: * Launches an insert object dialog (@c CEikInsertObjectDialog), williamr@2: * and inserts a default document of the application type selected williamr@2: * by the user. williamr@2: * williamr@2: * The object can be displayed either as a glass door, if supported, williamr@2: * or as an icon, and the inserted object is opened for editing. williamr@2: * williamr@2: * Displays an info message and leaves if the editor's text limit williamr@2: * has been reached. williamr@2: * williamr@2: * @param aFormat Specifies whether the embedded document should be williamr@2: * displayed as an icon or as a glass door. williamr@2: */ williamr@2: IMPORT_C void InsertObjectL(TObjectFormat aFormat); williamr@2: williamr@2: /** williamr@2: * Launches an insert object dialog (@c CEikInsertObjectDialog), williamr@2: * and inserts a default document of the application type selected williamr@2: * by the user. williamr@2: * williamr@2: * The object is displayed as a glass door rather than as an icon, williamr@2: * if supported and the inserted object is opened for editing. williamr@2: * williamr@2: * Displays an info message and leaves if the editor's text limit williamr@2: * has been reached. williamr@2: * williamr@2: * Default is @c EGlassIfPossible. williamr@2: */ williamr@2: IMPORT_C void InsertObjectL(); // defaults to EGlassIfPossible williamr@2: williamr@2: /** williamr@2: * Creates and inserts a default document of the specified williamr@2: * application type. williamr@2: * williamr@2: * @c CApaProcess::AddNewDocumentL() is used to create the document. williamr@2: * williamr@2: * The object can be displayed either as a glass door, if supported, williamr@2: * or as an icon, and the inserted object is opened for editing. williamr@2: * williamr@2: * Displays an info message and leaves if no suitable application DLL williamr@2: * can be found, or if the editor's text limit has been reached. williamr@2: * williamr@2: * @since Symbian 7.0 williamr@2: * @param aAppDllName Filename of the application DLL. williamr@2: * @param aAppDllUid UID of the application. The default is @c KNullUid. williamr@2: * @param aFormat Specifies whether the embedded document should be williamr@2: * displayed as an icon or as a glass door. williamr@2: */ williamr@2: IMPORT_C void InsertObjectL(const TDesC& aAppDllName, williamr@2: TUid aAppDllUid, williamr@2: TObjectFormat aFormat); williamr@2: williamr@2: /** williamr@2: * Creates and inserts a new embedded object of the specified type. williamr@2: * williamr@2: * First, an attempt is made to find an extended picture factory that williamr@2: * supports the insertion of pictures of the specified type. If one is williamr@2: * not found, the function leaves; if one is found, the picture is inserted williamr@2: * at the cursor position. williamr@2: * williamr@2: * Displays an info message and leaves if the editor's text limit has williamr@2: * been reached. williamr@2: * williamr@2: * @since Symbian 6.1 williamr@2: * @param aPictureType The picture type. williamr@2: * @param aData The base address of the data. williamr@2: * @leave KErrNotSupported No picture factory which supports the specified williamr@2: * type is available in the control's @c Uikon williamr@2: * environment. williamr@2: */ williamr@2: IMPORT_C void InsertObjectL(TUid aPictureType, williamr@2: CBase* aData); williamr@2: williamr@2: /** williamr@2: * Re-edits the embedded object at the cursor position. williamr@2: * williamr@2: * If there is no embedded object at the cursor position, or if there is a williamr@2: * selection, an info message is displayed. williamr@2: * williamr@2: * If there is a valid object at the cursor position, it is opened for williamr@2: * editing (or for viewing if the editor is read-only). williamr@2: */ williamr@2: IMPORT_C void ReEditObjectL(); williamr@2: williamr@2: /** williamr@2: * Gets the document position and checks whether there is an embedded williamr@2: * object at the cursor position. williamr@2: * williamr@2: * If there is no embedded object at the cursor position, or if there williamr@2: * is a selection, an info message is displayed. williamr@2: * williamr@2: * @return The document position of the embedded object, or williamr@2: * @c KErrNotFound if there is no embedded object at the cursor williamr@2: * position, or if there is a selection williamr@2: */ williamr@2: IMPORT_C TInt ObjectCursorPos() const; williamr@2: williamr@2: /** williamr@2: * Tests whether there is an embedded object at the cursor position. williamr@2: * williamr@2: * If there is one, it is opened for editing (or for viewing if the editor williamr@2: * is read-only). williamr@2: * williamr@2: * @return @c ETrue if there is an embedded object at the cursor williamr@2: * position and it could be opened. @c EFalse if there is no williamr@2: * embedded object at the cursor position, or if the object has williamr@2: * a NULL UID. williamr@2: */ williamr@2: IMPORT_C TBool CheckForObjectL(); williamr@2: williamr@2: /** williamr@2: * Launches a format object dialog (@c CEikFormatObjectDialog) if there williamr@2: * is an embedded object at the cursor position, and the object supports williamr@2: * being displayed as a glass door. williamr@2: * williamr@2: * If the object does not support being displayed as a glass door, an williamr@2: * object information dialog (@c CEikObjectInfoDialog) is launched instead. williamr@2: * williamr@2: * If the embedded object's associated application cannot be found, an williamr@2: * info message is displayed and the function leaves. williamr@2: * williamr@2: * The function has no effect if there is no embedded object at the cursor williamr@2: * position. williamr@2: */ williamr@2: IMPORT_C void EditPictureFormatL(); williamr@2: williamr@2: /** williamr@2: * Handles a change to the format of an embedded object, by updating the williamr@2: * view, the scroll bars and reporting the event to its observers. williamr@2: * williamr@2: * There is no need to call this function after calling williamr@2: * @c EditPictureFormatL(). williamr@2: */ williamr@2: IMPORT_C void PictureFormatChangedL(); williamr@2: williamr@2: /** williamr@2: * Gets a pointer to the embedded object located at the specified position. williamr@2: * williamr@2: * If the object is not in memory, the function loads it. williamr@2: * williamr@2: * If the object's associated application cannot be found, an info message williamr@2: * is displayed and the function leaves. williamr@2: * williamr@2: * @param aDoor On return, the embedded document's wrapper object (icon or williamr@2: * glass door). williamr@2: * @param aDoc On return, the embedded document. williamr@2: * @param aDocPos The document position in the editor at which the embedded williamr@2: * object is located. williamr@2: */ williamr@2: IMPORT_C void GetEmbeddedAppL(CApaDoor*& aDoor, williamr@2: CApaDocument*& aDoc, williamr@2: TInt aDocPos); williamr@2: williamr@2: /** williamr@2: * Changes all embedded objects displayed as glass doors into temporarily williamr@2: * iconic. williamr@2: * williamr@2: * The function operates throughout the editor. williamr@2: * williamr@2: * Only needed when pictures are temporarily iconic. williamr@2: * williamr@2: * Has no effect if there are no embedded objects in the editor or if the williamr@2: * @c EShowAllPicturesAsIconic attribute flag was set during construction. williamr@2: */ williamr@2: IMPORT_C void UpdatePictureFormatL(); williamr@2: williamr@2: /** williamr@2: * Changes all embedded objects displayed as glass doors into temporarily williamr@2: * iconic. williamr@2: * williamr@2: * The function operates over a specified range of characters. williamr@2: * williamr@2: * Has no effect if there are no embedded objects in the editor or if the williamr@2: * @c EShowAllPicturesAsIconic attribute flag was set during construction. williamr@2: * williamr@2: * Only needed when pictures are temporarily iconic. williamr@2: * williamr@2: * @param aStartPos The start position. williamr@2: * @param aLength The number of characters, beginning at @c aStartPos over williamr@2: * which the function operates. williamr@2: */ williamr@2: IMPORT_C void UpdatePictureFormatL(TInt aStartPos,TInt aLength); williamr@2: williamr@2: /** williamr@2: * Changes the size of the icons used to represent embedded objects. williamr@2: * williamr@2: * Any existing iconic doors can be updated to the new size by calling williamr@2: * @c UpdatePictureSizeL(). williamr@2: * williamr@2: * @param aSize The new iconic door size in twips. williamr@2: */ williamr@2: IMPORT_C void SetDefaultIconicDoorSize(const TSize& aSize); williamr@2: williamr@2: /** williamr@2: * Gets the size of iconic doors. williamr@2: * williamr@2: * @return The size of iconic doors. williamr@2: */ williamr@2: IMPORT_C const TSize& DefaultIconicDoorSize() const; williamr@2: williamr@2: /** williamr@2: * Changes the size of all icons representing embedded objects to the williamr@2: * default iconic door size. williamr@2: * williamr@2: * Also updates any objects currently displayed as glass doors, so that williamr@2: * if displayed as icons, they will use the correct size. williamr@2: * williamr@2: * The function operates throughout the editor. williamr@2: */ williamr@2: IMPORT_C void UpdatePictureSizeL(); williamr@2: williamr@2: /** williamr@2: * Changes the size of all icons representing embedded objects to the williamr@2: * default iconic door size. williamr@2: * williamr@2: * Also updates any objects currently displayed as glass doors, so that williamr@2: * if displayed as icons, they will use the correct size. williamr@2: * williamr@2: * The function operates over a specified range of characters. williamr@2: * williamr@2: * @param aStartPos The start position. williamr@2: * @param aLength The number of characters, beginning at @c aStartPos over williamr@2: * which the function operates. williamr@2: */ williamr@2: IMPORT_C void UpdatePictureSizeL(TInt aStartPos,TInt aLength); williamr@2: williamr@2: /** williamr@2: * Sets a parser observer. williamr@2: * williamr@2: * If the @c CEikEdwin::ENoTextParsers attribute flag was specified on williamr@2: * construction, this function has no effect. williamr@2: * williamr@2: * Its @c HandleCursorOverParserL() function is called when the cursor is williamr@2: * positioned over text that has been tagged by the parser, for instance williamr@2: * a URL. williamr@2: * williamr@2: * @param aObserver The parser observer. williamr@2: */ williamr@2: IMPORT_C void SetParserObserver( williamr@2: MEikRichTextEditorParserObserver* aObserver); williamr@2: williamr@2: /** williamr@2: * Activate/Disable phone number grouping. williamr@2: * williamr@2: * @param aEnable @c ETrue if phone number grouping is to be activated, williamr@2: * @c EFalse otherwise. williamr@2: */ williamr@2: IMPORT_C void SetPhoneNumberGrouping( TBool aEnable ); williamr@2: williamr@2: public: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles key events. williamr@2: * williamr@2: * Has no effect (apart from returning @c EKeyWasConsumed) if the williamr@2: * @c CEikEdwin::EDisplayOnly attribute flag was specified on construction. williamr@2: * williamr@2: * Handles rich text-specific hot keys, for instance to insert an object; williamr@2: * otherwise calls @c CEikGlobalTextEditor::OfferKeyEventL(). williamr@2: * williamr@2: * @param aKeyEvent The key event. williamr@2: * @param aType The type of the event. The editor only consumes events of williamr@2: * type @c EEventKey. williamr@2: * @return Indicates whether or not the editor consumed the williamr@2: * key event. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles pointer events inside the editor. williamr@2: * williamr@2: * Has no effect if the @c CEikEdwin::EDisplayOnly attribute flag was williamr@2: * specified on construction. williamr@2: * williamr@2: * @param aPointerEvent The pointer event to be handled. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Completes the construction of the rich text editor from a resource file. williamr@2: * williamr@2: * The editor's paragraph and character formatting are set to default williamr@2: * values, unless the @c CEikEdwin::EUserSuppliedText flag is specified in williamr@2: * the resource. williamr@2: * williamr@2: * @param aReader A resource reader positioned for reading from an williamr@2: * RTXTED resource. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Activates the editor so that it is ready for use. williamr@2: * williamr@2: * For instance, the text view is created, the editor is set to observe its williamr@2: * rich text object, the editor's parser manager is set up, which handles williamr@2: * the changes that occur when the cursor is moved over tagged text williamr@2: * (for instance a URL), and all embedded objects are set to be displayed williamr@2: * as icons, of the default size. williamr@2: */ williamr@2: IMPORT_C void ActivateL(); williamr@2: williamr@2: private: williamr@2: williamr@2: /** williamr@2: * From CAknControl. williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: public: // from CEikEdwin williamr@2: williamr@2: /** williamr@2: * From @c CEikEdwin. williamr@2: * williamr@2: * Copies the contents of one text object into another. williamr@2: * williamr@2: * @param[in] aInText The rich text object to copy. williamr@2: * @param[out] aOutText On return, contains a copy of @c aInText. williamr@2: * @panic 26 In debug mode, if either @c aInText or @c aOutText is @c NULL. williamr@2: */ williamr@2: IMPORT_C void CopyDocumentContentL(CGlobalText& aInText,CGlobalText& aOutText); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Internal flags used for indicating operations. williamr@2: */ williamr@2: enum // internal flags williamr@2: { williamr@2: /** Crop from left. */ williamr@2: ECropFromLeft =0x00010000, williamr@2: williamr@2: /** Crop from right. */ williamr@2: ECropFromRight =0x00020000, williamr@2: williamr@2: /** Crop from top. */ williamr@2: ECropFromTop =0x00040000, williamr@2: williamr@2: /** Crop from bottom. */ williamr@2: ECropFromBottom =0x00080000, williamr@2: williamr@2: /** Object is being re-edited. */ williamr@2: EReEditingObject =0x00100000 williamr@2: }; williamr@2: williamr@2: protected: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Writes the internal state to the specified stream. williamr@2: * williamr@2: * @param aWriteStream Target stream. williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: protected: // from MEditObserver williamr@2: williamr@2: /** williamr@2: * From @c MEditObserver. williamr@2: * williamr@2: * This member is internal an not meant to be used. williamr@2: * williamr@2: * @param aStartEdit Start position for editing. williamr@2: * @param aEditLength The length of the edited object. williamr@2: */ williamr@2: IMPORT_C void EditObserver(TInt aStartEdit,TInt aEditLength); williamr@2: williamr@2: private: // from CoeControl williamr@2: williamr@2: IMPORT_C void Draw(const TRect& aRect) const; williamr@2: williamr@2: IMPORT_C void Reserved_2(); williamr@2: williamr@2: private: // from CEikEdwin williamr@2: williamr@2: IMPORT_C void HandleTextPastedL(TInt aStartPos,TInt& aLength); williamr@2: IMPORT_C void Reserved_3(); williamr@2: williamr@2: private: // from MApaEmbeddedDocObserver williamr@2: williamr@2: IMPORT_C void NotifyExit(TExitMode aMode); williamr@2: williamr@2: private: // from MRichTextStoreResolver williamr@2: williamr@2: IMPORT_C const CStreamStore& StreamStoreL(TInt aPos) const; williamr@2: williamr@2: private: // from MPictureFactory williamr@2: williamr@2: IMPORT_C void NewPictureL(TPictureHeader& aHdr,const CStreamStore& aDeferredPictureStore) const; williamr@2: williamr@2: private: williamr@2: williamr@2: void CommonConstructL(); williamr@2: williamr@2: static TInt InsertEmbeddedDocL(TAny *aThis); williamr@2: williamr@2: static TInt DeleteEmbeddedDoc(TAny *aThis); williamr@2: williamr@2: static TInt UpdateEmbeddedDocL(TAny* aThis); williamr@2: williamr@2: static TInt TryDeleteEmbeddedDocL(TAny *aThis); williamr@2: williamr@2: void InsertPictureL(const TPictureHeader& aPictureHeader); williamr@2: williamr@2: void DoInsertPictureL(TBool& aFormatHasChanged,const TPictureHeader& aPictureHeader); williamr@2: williamr@2: void DoReEditObjectL(TInt aDocPos); williamr@2: williamr@2: void RoomForObjectL(); williamr@2: williamr@2: void InsertObjectL(CApaDocument* aDoc,TObjectFormat aFormat); williamr@2: williamr@2: void SetTextObserver(CRichText& aText); williamr@2: williamr@2: inline void DoReportEdwinEventL(MEikEdwinObserver::TEdwinEvent aEventType); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Default size of iconic door. williamr@2: */ williamr@2: TSize iDefaultIconicDoorSize; williamr@2: williamr@2: private: williamr@2: williamr@2: TPictureHeader iEmbeddedDoc; williamr@2: williamr@2: CIdle* iEmbeddedDocUpdate; williamr@2: williamr@2: CBufStore* iBufStore; williamr@2: williamr@2: CEikParserManager* iParserManager; williamr@2: williamr@2: private: williamr@2: williamr@2: friend class CEikParserManager; williamr@2: williamr@2: public: // new methods williamr@2: williamr@2: /** williamr@2: * Force everything to be parsed. williamr@2: */ williamr@2: IMPORT_C void RefreshParsersL(); williamr@2: williamr@2: }; williamr@2: williamr@2: class MEikRichTextEditorParserObserver williamr@2: { williamr@2: public: williamr@2: virtual void HandleCursorOverParserL(const TDesC& aDoItText)=0; williamr@2: }; williamr@2: williamr@2: inline void CEikRichTextEditor::DoReportEdwinEventL(MEikEdwinObserver::TEdwinEvent aEventType) williamr@2: {ReportEdwinEventL(aEventType);} williamr@2: williamr@2: #endif // __EIKRTED_H__ williamr@2: williamr@2: // End of file