2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * A UI control used by Smart Messaging Viewers.
26 #include <coecntrl.h> // CCoeControl
27 #include <badesca.h> // CDesC16ArrayFlat
28 #include <txtfrmat.h> // TCharFormat
29 #include <MsgEditor.hrh> // TMsgCursorLocation
34 * This enumeration defines the types of CRichBio
35 * No longer used meaningfully but defined for BC
40 ERichBioModeEditorBase,
44 // FORWARD DECLARATIONS
46 class CEikRichTextEditor;
47 class CMsgExpandableControlEditor;
50 * A UI control used by Smart Messaging Viewers.
51 * This control owns an editor, which is capable of viewing rich text content.
52 * NOTE! This is only intended for use with the Smart Message Viewers.
54 class CRichBio : public CCoeControl
56 public: // construction
59 * Two-phased constructor. Constructs the complete object.
60 * The parent control has to have a container window at this stage.
61 * The type (TRichBioMode) is legacy code and has no effect on the
62 * construction or use of the object. Either ERichBioModeEditorBase
63 * or ERichBioModeStandard can be used with the same effect
64 * @param aParent The parent control.
65 * @param aMode Either ERichBioModeEditorBase or ERichBioModeStandard
66 * @return a pointer to the created object.
68 IMPORT_C static CRichBio* NewL( const CCoeControl* aParent,
73 * ConstructL must be called after the container window is get.
74 * The type (TRichBioMode) is legacy code and has no effect on the
75 * construction or use of the object. Either ERichBioModeEditorBase
76 * or ERichBioModeStandard can be used with the same effect
77 * @param aMode Either ERichBioModeEditorBase or ERichBioModeStandard
79 IMPORT_C CRichBio( TRichBioMode aMode );
82 * Second phase constructor.
83 * The parent control has to have a container window at this stage.
84 * @param aParent The parent control, which has container window.
86 IMPORT_C void ConstructL( const CCoeControl* aParent );
88 public: // destruction
95 public: // own methods
98 * Adds a label and value pair.
99 * The client does not need to check the length of the strings. This function will
100 * wrap strings that are too long.
101 * @param aLabel text to displayed in label text format.
102 * @param aValue text to displayed in text format.
104 IMPORT_C void AddItemL(const TDesC& aLabel, const TDesC& aValue);
107 * This is needed for scrolling with Editor Base.
108 * @return TRect Returns the rectangle of the "current" line.
110 IMPORT_C TRect CurrentLineRect();
113 * For accessing the richtext editor.
114 * Must not be called before ConstructL has been called.
115 * @return Reference to the CEikRichTextEditor
116 * @exception Panics if the iEditor is NULL.
118 IMPORT_C CEikRichTextEditor& Editor();
121 * Is the editor base mode on.
122 * @return ETrue if it is in Editor Base mode.
124 IMPORT_C TBool IsEditorBaseMode() const;
127 * Empties the data contents.
129 IMPORT_C void Reset();
132 * Returns the preferred size of the control.
133 * @param aSize Control may set its preferred size
135 IMPORT_C void SetAndGetSizeL( TSize& aSize );
138 * Returns the rich text virtual length.
139 * @return text length in rich text.
141 IMPORT_C TInt VirtualHeight();
144 * Returns the current cursor position.
145 * Even in the viewer mode control contains a hidden cursor.
146 * This method return its position.
147 * @return a position of the hidden cursor relative to the virtual length.
149 IMPORT_C TInt VirtualVisibleTop();
152 * Find out if the cursor is at a certain position.
153 * @param aLocation indicates either that the cursor is at the topmost
154 * position of the control or at the bottom most position.
155 * @return ETrue if the cursor is at the specified position, EFalse otherwise.
157 IMPORT_C TBool IsCursorLocation(TMsgCursorLocation aLocation) const;
160 * Performs the internal scrolling of control if needed.
163 * @param aPixelsToScroll Amount of pixels to scroll.
164 * @param aDirection Scrolling direction.
165 * @return Amount of pixels the where scrolled. Zero value means the component cannot
166 * be scrolled to that direction anymore
169 IMPORT_C TInt ScrollL( TInt aPixelsToScroll, TMsgScrollDirection aDirection );
172 * Prepares control for viewing.
174 * @param aEvent The event type
175 * @param aParam Event related parameters
177 IMPORT_C void NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam );
179 public: // from CCoeControl
181 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
183 private: // Helper methods.
186 * Applies the format of label text to viewer.
187 * @param aFormat Character format to be applied.
188 * @param aMask Character format mask
190 void ApplyLabelFormat(TCharFormat& aFormat, TCharFormatMask& aMask);
193 * Applies the format of value text to viewer.
194 * @param aFormat Character format to be applied.
195 * @param aMask Character format mask
197 void ApplyValueFormat(TCharFormat& aFormat, TCharFormatMask& aMask);
200 * Applies the format of value and label text to viewer.
201 * @param aFormat Character format to be applied.
202 * @param aMask Character format mask
203 * @aIsLabel Determines is the text label or value.
205 void ApplyFormat(TCharFormat& aFormat, TCharFormatMask& aMask, TBool aIsLabel);
208 * Appends text to RichText viewer.
209 * @param aLabel Label text
210 * @param aValue value text
212 void AddItemToRichTextL(const TDesC& aLabel, const TDesC& aValue);
215 * Add text to viewer, checks and removes linefeeds and carriage returns
216 * @param aText text to be added
217 * @param aFormat Character format
218 * @param aMask Character format mask
220 void AppendTextL( const TDesC& aText,
221 const TCharFormat& aFormat,
222 const TCharFormatMask& aMask );
225 * Checks either cache exists or not.
226 * @return TBool exists cache or not
231 * Adds items to richtext from cache.
233 void LoadFromCacheL();
237 * @param aLabel label text
238 * @param aValue value text
240 void CacheItemL(const TDesC& aLabel, const TDesC& aValue);
244 * @param aCode panic code.
246 static void Panic( TInt aPanic );
253 * Default constructor prohibited
258 * Copy constructor hidden away.
260 CRichBio(const CRichBio& aSource);
263 * Assignment operator hidden away.
265 const CRichBio& operator=(const CRichBio& aSource);
267 private: // from CCoeControl
269 void Draw(const TRect& aRect) const;
271 TInt CountComponentControls() const;
273 CCoeControl* ComponentControl(TInt aIndex) const;
279 /// Introduce inner class.
280 class CEdwinSizeObserver;
282 /// Declare inner class friend.
283 friend class CEdwinSizeObserver;
285 /// Pointer to the editor size observer.
286 CEdwinSizeObserver* iEdwinSizeObserver;
289 CMsgExpandableControlEditor* iEditor;
291 /// preserved for binary compatibility
294 // startup cache for data
295 CDesC16ArrayFlat* iLabelCache;
297 // startup cache for data
298 CDesC16ArrayFlat* iValueCache;
300 // Editor Base mode on or off.
301 const TRichBioMode iMode;
307 friend class T_RichBioTestSuite;
310 #endif //_CRICHBIO_H_