2 * Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #if !defined(__EIKRTED_H__)
22 #if !defined(__EIKGTED_H__)
26 #if !defined(__APPARC_H__)
30 #if !defined(__TXTMRTSR_H__)
34 #if !defined(__GDI_H__)
39 class TResourceReader;
45 class CEikParserManager;
46 class MEikRichTextEditorParserObserver;
52 * This is an edit window that supports rich text, including embedded objects
53 * represented either by icons or glass doors.
57 class CEikRichTextEditor : public CEikGlobalTextEditor,
58 public MApaEmbeddedDocObserver,
59 public MRichTextStoreResolver,
60 public MPictureFactory
66 * Identifies how an embedded object should be represented.
68 * One of these values is specified when the object is inserted.
72 /** The object is always represented by an icon */
76 * The object is represented by a glass door, if possible, or by icon,
83 * Edit window attribute flags specific to the rich text editor.
85 * These may be specified during construction in addition to the values
86 * contained in the @c TFlags enum in class @c CEikEdwin.
91 * All embedded objects are represented by icon rather than
94 EShowAllPicturesAsIconic =0x00100000,
97 * The editor has no text parsers.
99 * Text parsers are used to recognise and tag special text strings,
102 ENoTextParsers =0x00200000,
105 * When pasting text into the editor, the text is
106 * stripped of all formatting.
110 EPasteAsPlainText =0x00400000
116 * C++ default constructor.
118 IMPORT_C CEikRichTextEditor();
123 * @param aBorder Border for the rich text editor.
125 IMPORT_C CEikRichTextEditor(const TGulBorder& aBorder);
130 IMPORT_C ~CEikRichTextEditor();
133 * By default Symbian 2nd phase constructor is private.
135 * Completes construction of the rich text editor.
137 * The editor's paragraph and character formatting are set to default
138 * values, unless the @c CEikEdwin::EUserSuppliedText flag is specified
141 * @param aParent If not NULL, the editor's parent control.
142 * If NULL, the editor has no parent.
143 * @param aNumberOfLines The number of lines visible in the editor.
144 * This controls the editor's height.
145 * @param aTextLimit The maximum number of characters that can be entered
147 * @param aEdwinFlags Edit window attribute flags.
148 * See @c CEikEdwin::TFlags().
149 * @param aFontControlFlags = EGulFontControlAll Flags that specify which
150 * font-related controls should not appear in font dialogs launched
151 * from the edit window. For instance @c EGulFontControlBold removes
152 * the bold checkbox control. The default shows all. For possible
153 * values, see @c gulftflg.hrh.
154 * @param aFontNameFlags = EGulNoSymbolFonts The font flags. These control
155 * whether symbol and monospace fonts should be displayed in font
156 * dialogs launched from the edit window. For possible values, see
159 IMPORT_C void ConstructL(const CCoeControl* aParent,
163 TInt aFontControlFlags=EGulFontControlAll,
164 TInt aFontNameFlags=EGulNoSymbolFonts);
167 * Gets a pointer to the rich text object owned by the editor.
169 * @return Pointer to the rich text object.
171 IMPORT_C CRichText* RichText() const;
174 * Launches an insert object dialog (@c CEikInsertObjectDialog),
175 * and inserts a default document of the application type selected
178 * The object can be displayed either as a glass door, if supported,
179 * or as an icon, and the inserted object is opened for editing.
181 * Displays an info message and leaves if the editor's text limit
184 * @param aFormat Specifies whether the embedded document should be
185 * displayed as an icon or as a glass door.
187 IMPORT_C void InsertObjectL(TObjectFormat aFormat);
190 * Launches an insert object dialog (@c CEikInsertObjectDialog),
191 * and inserts a default document of the application type selected
194 * The object is displayed as a glass door rather than as an icon,
195 * if supported and the inserted object is opened for editing.
197 * Displays an info message and leaves if the editor's text limit
200 * Default is @c EGlassIfPossible.
202 IMPORT_C void InsertObjectL(); // defaults to EGlassIfPossible
205 * Creates and inserts a default document of the specified
208 * @c CApaProcess::AddNewDocumentL() is used to create the document.
210 * The object can be displayed either as a glass door, if supported,
211 * or as an icon, and the inserted object is opened for editing.
213 * Displays an info message and leaves if no suitable application DLL
214 * can be found, or if the editor's text limit has been reached.
217 * @param aAppDllName Filename of the application DLL.
218 * @param aAppDllUid UID of the application. The default is @c KNullUid.
219 * @param aFormat Specifies whether the embedded document should be
220 * displayed as an icon or as a glass door.
222 IMPORT_C void InsertObjectL(const TDesC& aAppDllName,
224 TObjectFormat aFormat);
227 * Creates and inserts a new embedded object of the specified type.
229 * First, an attempt is made to find an extended picture factory that
230 * supports the insertion of pictures of the specified type. If one is
231 * not found, the function leaves; if one is found, the picture is inserted
232 * at the cursor position.
234 * Displays an info message and leaves if the editor's text limit has
238 * @param aPictureType The picture type.
239 * @param aData The base address of the data.
240 * @leave KErrNotSupported No picture factory which supports the specified
241 * type is available in the control's @c Uikon
244 IMPORT_C void InsertObjectL(TUid aPictureType,
248 * Re-edits the embedded object at the cursor position.
250 * If there is no embedded object at the cursor position, or if there is a
251 * selection, an info message is displayed.
253 * If there is a valid object at the cursor position, it is opened for
254 * editing (or for viewing if the editor is read-only).
256 IMPORT_C void ReEditObjectL();
259 * Gets the document position and checks whether there is an embedded
260 * object at the cursor position.
262 * If there is no embedded object at the cursor position, or if there
263 * is a selection, an info message is displayed.
265 * @return The document position of the embedded object, or
266 * @c KErrNotFound if there is no embedded object at the cursor
267 * position, or if there is a selection
269 IMPORT_C TInt ObjectCursorPos() const;
272 * Tests whether there is an embedded object at the cursor position.
274 * If there is one, it is opened for editing (or for viewing if the editor
277 * @return @c ETrue if there is an embedded object at the cursor
278 * position and it could be opened. @c EFalse if there is no
279 * embedded object at the cursor position, or if the object has
282 IMPORT_C TBool CheckForObjectL();
285 * Launches a format object dialog (@c CEikFormatObjectDialog) if there
286 * is an embedded object at the cursor position, and the object supports
287 * being displayed as a glass door.
289 * If the object does not support being displayed as a glass door, an
290 * object information dialog (@c CEikObjectInfoDialog) is launched instead.
292 * If the embedded object's associated application cannot be found, an
293 * info message is displayed and the function leaves.
295 * The function has no effect if there is no embedded object at the cursor
298 IMPORT_C void EditPictureFormatL();
301 * Handles a change to the format of an embedded object, by updating the
302 * view, the scroll bars and reporting the event to its observers.
304 * There is no need to call this function after calling
305 * @c EditPictureFormatL().
307 IMPORT_C void PictureFormatChangedL();
310 * Gets a pointer to the embedded object located at the specified position.
312 * If the object is not in memory, the function loads it.
314 * If the object's associated application cannot be found, an info message
315 * is displayed and the function leaves.
317 * @param aDoor On return, the embedded document's wrapper object (icon or
319 * @param aDoc On return, the embedded document.
320 * @param aDocPos The document position in the editor at which the embedded
323 IMPORT_C void GetEmbeddedAppL(CApaDoor*& aDoor,
328 * Changes all embedded objects displayed as glass doors into temporarily
331 * The function operates throughout the editor.
333 * Only needed when pictures are temporarily iconic.
335 * Has no effect if there are no embedded objects in the editor or if the
336 * @c EShowAllPicturesAsIconic attribute flag was set during construction.
338 IMPORT_C void UpdatePictureFormatL();
341 * Changes all embedded objects displayed as glass doors into temporarily
344 * The function operates over a specified range of characters.
346 * Has no effect if there are no embedded objects in the editor or if the
347 * @c EShowAllPicturesAsIconic attribute flag was set during construction.
349 * Only needed when pictures are temporarily iconic.
351 * @param aStartPos The start position.
352 * @param aLength The number of characters, beginning at @c aStartPos over
353 * which the function operates.
355 IMPORT_C void UpdatePictureFormatL(TInt aStartPos,TInt aLength);
358 * Changes the size of the icons used to represent embedded objects.
360 * Any existing iconic doors can be updated to the new size by calling
361 * @c UpdatePictureSizeL().
363 * @param aSize The new iconic door size in twips.
365 IMPORT_C void SetDefaultIconicDoorSize(const TSize& aSize);
368 * Gets the size of iconic doors.
370 * @return The size of iconic doors.
372 IMPORT_C const TSize& DefaultIconicDoorSize() const;
375 * Changes the size of all icons representing embedded objects to the
376 * default iconic door size.
378 * Also updates any objects currently displayed as glass doors, so that
379 * if displayed as icons, they will use the correct size.
381 * The function operates throughout the editor.
383 IMPORT_C void UpdatePictureSizeL();
386 * Changes the size of all icons representing embedded objects to the
387 * default iconic door size.
389 * Also updates any objects currently displayed as glass doors, so that
390 * if displayed as icons, they will use the correct size.
392 * The function operates over a specified range of characters.
394 * @param aStartPos The start position.
395 * @param aLength The number of characters, beginning at @c aStartPos over
396 * which the function operates.
398 IMPORT_C void UpdatePictureSizeL(TInt aStartPos,TInt aLength);
401 * Sets a parser observer.
403 * If the @c CEikEdwin::ENoTextParsers attribute flag was specified on
404 * construction, this function has no effect.
406 * Its @c HandleCursorOverParserL() function is called when the cursor is
407 * positioned over text that has been tagged by the parser, for instance
410 * @param aObserver The parser observer.
412 IMPORT_C void SetParserObserver(
413 MEikRichTextEditorParserObserver* aObserver);
416 * Activate/Disable phone number grouping.
418 * @param aEnable @c ETrue if phone number grouping is to be activated,
419 * @c EFalse otherwise.
421 IMPORT_C void SetPhoneNumberGrouping( TBool aEnable );
423 public: // from CCoeControl
426 * From @c CCoeControl.
428 * Handles key events.
430 * Has no effect (apart from returning @c EKeyWasConsumed) if the
431 * @c CEikEdwin::EDisplayOnly attribute flag was specified on construction.
433 * Handles rich text-specific hot keys, for instance to insert an object;
434 * otherwise calls @c CEikGlobalTextEditor::OfferKeyEventL().
436 * @param aKeyEvent The key event.
437 * @param aType The type of the event. The editor only consumes events of
439 * @return Indicates whether or not the editor consumed the
442 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
445 * From @c CCoeControl.
447 * Handles pointer events inside the editor.
449 * Has no effect if the @c CEikEdwin::EDisplayOnly attribute flag was
450 * specified on construction.
452 * @param aPointerEvent The pointer event to be handled.
454 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
457 * From @c CCoeControl.
459 * Completes the construction of the rich text editor from a resource file.
461 * The editor's paragraph and character formatting are set to default
462 * values, unless the @c CEikEdwin::EUserSuppliedText flag is specified in
465 * @param aReader A resource reader positioned for reading from an
468 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
471 * From @c CCoeControl.
473 * Activates the editor so that it is ready for use.
475 * For instance, the text view is created, the editor is set to observe its
476 * rich text object, the editor's parser manager is set up, which handles
477 * the changes that occur when the cursor is moved over tagged text
478 * (for instance a URL), and all embedded objects are set to be displayed
479 * as icons, of the default size.
481 IMPORT_C void ActivateL();
488 IMPORT_C void* ExtensionInterface( TUid aInterface );
490 public: // from CEikEdwin
495 * Copies the contents of one text object into another.
497 * @param[in] aInText The rich text object to copy.
498 * @param[out] aOutText On return, contains a copy of @c aInText.
499 * @panic 26 In debug mode, if either @c aInText or @c aOutText is @c NULL.
501 IMPORT_C void CopyDocumentContentL(CGlobalText& aInText,CGlobalText& aOutText);
506 * Internal flags used for indicating operations.
508 enum // internal flags
510 /** Crop from left. */
511 ECropFromLeft =0x00010000,
513 /** Crop from right. */
514 ECropFromRight =0x00020000,
516 /** Crop from top. */
517 ECropFromTop =0x00040000,
519 /** Crop from bottom. */
520 ECropFromBottom =0x00080000,
522 /** Object is being re-edited. */
523 EReEditingObject =0x00100000
526 protected: // from CCoeControl
529 * From @c CCoeControl.
531 * Writes the internal state to the specified stream.
533 * @param aWriteStream Target stream.
535 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
537 protected: // from MEditObserver
540 * From @c MEditObserver.
542 * This member is internal an not meant to be used.
544 * @param aStartEdit Start position for editing.
545 * @param aEditLength The length of the edited object.
547 IMPORT_C void EditObserver(TInt aStartEdit,TInt aEditLength);
549 private: // from CoeControl
551 IMPORT_C void Draw(const TRect& aRect) const;
553 IMPORT_C void Reserved_2();
555 private: // from CEikEdwin
557 IMPORT_C void HandleTextPastedL(TInt aStartPos,TInt& aLength);
558 IMPORT_C void Reserved_3();
560 private: // from MApaEmbeddedDocObserver
562 IMPORT_C void NotifyExit(TExitMode aMode);
564 private: // from MRichTextStoreResolver
566 IMPORT_C const CStreamStore& StreamStoreL(TInt aPos) const;
568 private: // from MPictureFactory
570 IMPORT_C void NewPictureL(TPictureHeader& aHdr,const CStreamStore& aDeferredPictureStore) const;
574 void CommonConstructL();
576 static TInt InsertEmbeddedDocL(TAny *aThis);
578 static TInt DeleteEmbeddedDoc(TAny *aThis);
580 static TInt UpdateEmbeddedDocL(TAny* aThis);
582 static TInt TryDeleteEmbeddedDocL(TAny *aThis);
584 void InsertPictureL(const TPictureHeader& aPictureHeader);
586 void DoInsertPictureL(TBool& aFormatHasChanged,const TPictureHeader& aPictureHeader);
588 void DoReEditObjectL(TInt aDocPos);
590 void RoomForObjectL();
592 void InsertObjectL(CApaDocument* aDoc,TObjectFormat aFormat);
594 void SetTextObserver(CRichText& aText);
596 inline void DoReportEdwinEventL(MEikEdwinObserver::TEdwinEvent aEventType);
601 * Default size of iconic door.
603 TSize iDefaultIconicDoorSize;
607 TPictureHeader iEmbeddedDoc;
609 CIdle* iEmbeddedDocUpdate;
611 CBufStore* iBufStore;
613 CEikParserManager* iParserManager;
617 friend class CEikParserManager;
619 public: // new methods
622 * Force everything to be parsed.
624 IMPORT_C void RefreshParsersL();
628 class MEikRichTextEditorParserObserver
631 virtual void HandleCursorOverParserL(const TDesC& aDoItText)=0;
634 inline void CEikRichTextEditor::DoReportEdwinEventL(MEikEdwinObserver::TEdwinEvent aEventType)
635 {ReportEdwinEventL(aEventType);}
637 #endif // __EIKRTED_H__