williamr@2: /* williamr@2: * Copyright (c) 2002 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: * A UI control used by Smart Messaging Viewers. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef _CRICHBIO_H_ williamr@2: #define _CRICHBIO_H_ williamr@2: williamr@2: // INCLUDES williamr@2: williamr@2: #include // CCoeControl williamr@2: #include // CDesC16ArrayFlat williamr@2: #include // TCharFormat williamr@2: #include // TMsgCursorLocation williamr@2: williamr@2: // DATA TYPES williamr@2: williamr@2: /** williamr@2: * This enumeration defines the types of CRichBio williamr@2: * No longer used meaningfully but defined for BC williamr@2: * williamr@2: */ williamr@2: enum TRichBioMode williamr@2: { williamr@2: ERichBioModeEditorBase, williamr@2: ERichBioModeStandard williamr@2: }; williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: williamr@2: class CEikRichTextEditor; williamr@2: class CMsgExpandableControlEditor; williamr@2: williamr@2: /** williamr@2: * A UI control used by Smart Messaging Viewers. williamr@2: * This control owns an editor, which is capable of viewing rich text content. williamr@2: * NOTE! This is only intended for use with the Smart Message Viewers. williamr@2: */ williamr@2: class CRichBio : public CCoeControl williamr@2: { williamr@2: public: // construction williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs the complete object. williamr@2: * The parent control has to have a container window at this stage. williamr@2: * The type (TRichBioMode) is legacy code and has no effect on the williamr@2: * construction or use of the object. Either ERichBioModeEditorBase williamr@2: * or ERichBioModeStandard can be used with the same effect williamr@2: * @param aParent The parent control. williamr@2: * @param aMode Either ERichBioModeEditorBase or ERichBioModeStandard williamr@2: * @return a pointer to the created object. williamr@2: */ williamr@2: IMPORT_C static CRichBio* NewL( const CCoeControl* aParent, williamr@2: TRichBioMode aMode ); williamr@2: williamr@2: /** williamr@2: * Constructor. williamr@2: * ConstructL must be called after the container window is get. williamr@2: * The type (TRichBioMode) is legacy code and has no effect on the williamr@2: * construction or use of the object. Either ERichBioModeEditorBase williamr@2: * or ERichBioModeStandard can be used with the same effect williamr@2: * @param aMode Either ERichBioModeEditorBase or ERichBioModeStandard williamr@2: */ williamr@2: IMPORT_C CRichBio( TRichBioMode aMode ); williamr@2: williamr@2: /** williamr@2: * Second phase constructor. williamr@2: * The parent control has to have a container window at this stage. williamr@2: * @param aParent The parent control, which has container window. williamr@2: */ williamr@2: IMPORT_C void ConstructL( const CCoeControl* aParent ); williamr@2: williamr@2: public: // destruction williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: ~CRichBio(); williamr@2: williamr@2: public: // own methods williamr@2: williamr@2: /** williamr@2: * Adds a label and value pair. williamr@2: * The client does not need to check the length of the strings. This function will williamr@2: * wrap strings that are too long. williamr@2: * @param aLabel text to displayed in label text format. williamr@2: * @param aValue text to displayed in text format. williamr@2: */ williamr@2: IMPORT_C void AddItemL(const TDesC& aLabel, const TDesC& aValue); williamr@2: williamr@2: /** williamr@2: * This is needed for scrolling with Editor Base. williamr@2: * @return TRect Returns the rectangle of the "current" line. williamr@2: */ williamr@2: IMPORT_C TRect CurrentLineRect(); williamr@2: williamr@2: /** williamr@2: * For accessing the richtext editor. williamr@2: * Must not be called before ConstructL has been called. williamr@2: * @return Reference to the CEikRichTextEditor williamr@2: * @exception Panics if the iEditor is NULL. williamr@2: */ williamr@2: IMPORT_C CEikRichTextEditor& Editor(); williamr@2: williamr@2: /** williamr@2: * Is the editor base mode on. williamr@2: * @return ETrue if it is in Editor Base mode. williamr@2: */ williamr@2: IMPORT_C TBool IsEditorBaseMode() const; williamr@2: williamr@2: /** williamr@2: * Empties the data contents. williamr@2: */ williamr@2: IMPORT_C void Reset(); williamr@2: williamr@2: /** williamr@2: * Returns the preferred size of the control. williamr@2: * @param aSize Control may set its preferred size williamr@2: */ williamr@2: IMPORT_C void SetAndGetSizeL( TSize& aSize ); williamr@2: williamr@2: /** williamr@2: * Returns the rich text virtual length. williamr@2: * @return text length in rich text. williamr@2: */ williamr@2: IMPORT_C TInt VirtualHeight(); williamr@2: williamr@2: /** williamr@2: * Returns the current cursor position. williamr@2: * Even in the viewer mode control contains a hidden cursor. williamr@2: * This method return its position. williamr@2: * @return a position of the hidden cursor relative to the virtual length. williamr@2: */ williamr@2: IMPORT_C TInt VirtualVisibleTop(); williamr@2: williamr@2: /** williamr@2: * Find out if the cursor is at a certain position. williamr@2: * @param aLocation indicates either that the cursor is at the topmost williamr@2: * position of the control or at the bottom most position. williamr@2: * @return ETrue if the cursor is at the specified position, EFalse otherwise. williamr@2: */ williamr@2: IMPORT_C TBool IsCursorLocation(TMsgCursorLocation aLocation) const; williamr@2: williamr@2: /** williamr@2: * Performs the internal scrolling of control if needed. williamr@2: * @since 3.2 williamr@2: * williamr@2: * @param aPixelsToScroll Amount of pixels to scroll. williamr@2: * @param aDirection Scrolling direction. williamr@2: * @return Amount of pixels the where scrolled. Zero value means the component cannot williamr@2: * be scrolled to that direction anymore williamr@2: */ williamr@2: williamr@2: IMPORT_C TInt ScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection ); williamr@2: williamr@2: /** williamr@2: * Prepares control for viewing. williamr@2: * @since 3.2 williamr@2: * @param aEvent The event type williamr@2: * @param aParam Event related parameters williamr@2: */ williamr@2: IMPORT_C void NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam ); williamr@2: williamr@2: public: // from CCoeControl williamr@2: williamr@2: TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: private: // Helper methods. williamr@2: williamr@2: /** williamr@2: * Applies the format of label text to viewer. williamr@2: * @param aFormat Character format to be applied. williamr@2: * @param aMask Character format mask williamr@2: */ williamr@2: void ApplyLabelFormat(TCharFormat& aFormat, TCharFormatMask& aMask); williamr@2: williamr@2: /** williamr@2: * Applies the format of value text to viewer. williamr@2: * @param aFormat Character format to be applied. williamr@2: * @param aMask Character format mask williamr@2: */ williamr@2: void ApplyValueFormat(TCharFormat& aFormat, TCharFormatMask& aMask); williamr@2: williamr@2: /** williamr@2: * Applies the format of value and label text to viewer. williamr@2: * @param aFormat Character format to be applied. williamr@2: * @param aMask Character format mask williamr@2: * @aIsLabel Determines is the text label or value. williamr@2: */ williamr@2: void ApplyFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TBool aIsLabel); williamr@2: williamr@2: /** williamr@2: * Appends text to RichText viewer. williamr@2: * @param aLabel Label text williamr@2: * @param aValue value text williamr@2: */ williamr@2: void AddItemToRichTextL(const TDesC& aLabel, const TDesC& aValue); williamr@2: williamr@2: /** williamr@2: * Add text to viewer, checks and removes linefeeds and carriage returns williamr@2: * @param aText text to be added williamr@2: * @param aFormat Character format williamr@2: * @param aMask Character format mask williamr@2: */ williamr@2: void AppendTextL( const TDesC& aText, williamr@2: const TCharFormat& aFormat, williamr@2: const TCharFormatMask& aMask ); williamr@2: williamr@2: /** williamr@2: * Checks either cache exists or not. williamr@2: * @return TBool exists cache or not williamr@2: */ williamr@2: TBool CacheExists(); williamr@2: williamr@2: /** williamr@2: * Adds items to richtext from cache. williamr@2: */ williamr@2: void LoadFromCacheL(); williamr@2: williamr@2: /** williamr@2: * Adds item to cache williamr@2: * @param aLabel label text williamr@2: * @param aValue value text williamr@2: */ williamr@2: void CacheItemL(const TDesC& aLabel, const TDesC& aValue); williamr@2: williamr@2: /** williamr@2: * panic wrapper williamr@2: * @param aCode panic code. williamr@2: */ williamr@2: static void Panic( TInt aPanic ); williamr@2: williamr@2: williamr@2: williamr@2: private: williamr@2: williamr@2: /** williamr@2: * Default constructor prohibited williamr@2: */ williamr@2: CRichBio(); williamr@2: williamr@2: /** williamr@2: * Copy constructor hidden away. williamr@2: */ williamr@2: CRichBio(const CRichBio& aSource); williamr@2: williamr@2: /** williamr@2: * Assignment operator hidden away. williamr@2: */ williamr@2: const CRichBio& operator=(const CRichBio& aSource); williamr@2: williamr@2: private: // from CCoeControl williamr@2: williamr@2: void Draw(const TRect& aRect) const; williamr@2: williamr@2: TInt CountComponentControls() const; williamr@2: williamr@2: CCoeControl* ComponentControl(TInt aIndex) const; williamr@2: williamr@2: void SizeChanged(); williamr@2: williamr@2: private: williamr@2: williamr@2: /// Introduce inner class. williamr@2: class CEdwinSizeObserver; williamr@2: williamr@2: /// Declare inner class friend. williamr@2: friend class CEdwinSizeObserver; williamr@2: williamr@2: /// Pointer to the editor size observer. williamr@2: CEdwinSizeObserver* iEdwinSizeObserver; williamr@2: williamr@2: /// Editor control williamr@2: CMsgExpandableControlEditor* iEditor; williamr@2: williamr@2: /// preserved for binary compatibility williamr@2: TInt iVirtualHeight; williamr@2: williamr@2: // startup cache for data williamr@2: CDesC16ArrayFlat* iLabelCache; williamr@2: williamr@2: // startup cache for data williamr@2: CDesC16ArrayFlat* iValueCache; williamr@2: williamr@2: // Editor Base mode on or off. williamr@2: const TRichBioMode iMode; williamr@2: williamr@2: /// is first item williamr@2: TBool iIsFirstItem; williamr@2: williamr@2: private: williamr@2: friend class T_RichBioTestSuite; williamr@2: }; williamr@2: williamr@2: #endif //_CRICHBIO_H_ williamr@2: williamr@2: // end of file