1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: FreestyleEmailUi mail viewer rich text definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __FREESTYLEEMAILUI_MAILVIEWERRICHTEXT_H__ |
|
21 #define __FREESTYLEEMAILUI_MAILVIEWERRICHTEXT_H__ |
|
22 |
|
23 // SYSTEM INCLUDE FILES |
|
24 #include <e32base.h> |
|
25 #include <finditemengine.h> |
|
26 //<cmail> |
|
27 #include <alf/alfanchorlayout.h> |
|
28 //</cmail> |
|
29 |
|
30 // Forward declarations |
|
31 class CAknLayoutFont; |
|
32 class CFSMailMessage; |
|
33 class CFSMailBox; |
|
34 class CFsTextViewer; |
|
35 class CFsRichText; |
|
36 class CFreestyleEmailUiAppUi; |
|
37 class CAlfTextVisual; |
|
38 |
|
39 // Header data |
|
40 struct SMailMsgHeaderInfo |
|
41 { |
|
42 TInt iHeaderLineCount; |
|
43 TInt iToLineCount; |
|
44 TInt iCcLineCount; |
|
45 TInt iSubjectLineCount; |
|
46 TBool iFlagIconOnHtmlLine; |
|
47 }; |
|
48 |
|
49 // Different hotspot types |
|
50 enum TViewerHeadingHotspotType |
|
51 { |
|
52 ETypeFromAddressDisplayName = 0, |
|
53 ETypeToAddressDisplayName, |
|
54 ETypeCcAddressDisplayName, |
|
55 ETypeBccAddressDisplayName, |
|
56 ETypeEmailAddress, |
|
57 ETypeToNMoreRecipients, |
|
58 ETypeCcNMoreRecipients, |
|
59 ETypeBccNMoreRecipients, |
|
60 ETypeAttachment, |
|
61 ETypeAttachments, |
|
62 ETypeHtml |
|
63 }; |
|
64 |
|
65 // Different recipient types |
|
66 enum TViewerRecipientType |
|
67 { |
|
68 EViewerRecipientTypeTo = 0, |
|
69 EViewerRecipientTypeCc, |
|
70 EViewerRecipientTypeBcc |
|
71 }; |
|
72 |
|
73 |
|
74 // Struct for one header hotspot data |
|
75 struct SViewerHeadingHotSpotData |
|
76 { |
|
77 TViewerHeadingHotspotType iType; |
|
78 TInt iStart; |
|
79 TInt iEnd; |
|
80 TInt iDisplayNameArrayIndex; |
|
81 TInt iHotspotLine; |
|
82 }; |
|
83 |
|
84 // Body and header hotspots are different |
|
85 enum THotspotType |
|
86 { |
|
87 ENoHotspot, |
|
88 EHeaderHotspot, |
|
89 EBodyHotspot |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 * CFSEmailUiMailViewerRichText is a rich text for the mail viewer visualiser |
|
95 * |
|
96 */ |
|
97 class CFSEmailUiMailViewerRichText : public CBase |
|
98 { |
|
99 public: |
|
100 static CFSEmailUiMailViewerRichText* NewL( CFreestyleEmailUiAppUi& aFsTextureManager ); |
|
101 static CFSEmailUiMailViewerRichText* NewLC( CFreestyleEmailUiAppUi& aFsTextureManager ); |
|
102 |
|
103 virtual ~CFSEmailUiMailViewerRichText(); |
|
104 |
|
105 void RefreshRichTextL( CFsTextViewer& aTextViewer, CFSMailMessage& aMessage, CFSMailBox& aMailBox ); |
|
106 void Reset(); |
|
107 |
|
108 // Provides handle to richtext |
|
109 CFsRichText& RichText(); |
|
110 |
|
111 // Getters for text lines |
|
112 TInt SentTextLine() const; |
|
113 TInt SubjectTextLine() const; |
|
114 TInt AttachmentTextLine() const; |
|
115 TInt ViewHtmlTextLine() const; |
|
116 TInt HeaderLengthInCharacters() const; |
|
117 |
|
118 // Getters for hotspot indicies |
|
119 TInt AttachmentHotSpotIndex() const; |
|
120 TInt ViewHtmlHotSpotIndex() const; |
|
121 |
|
122 // Icon updating |
|
123 |
|
124 // Different icon types presented in message viewer. |
|
125 enum TViewerIconType |
|
126 { |
|
127 // status icon |
|
128 EViewerEmailStatus, |
|
129 // follow up |
|
130 EViewerIconFollowUp, |
|
131 EViewerIconFollowUpComplete, |
|
132 EViewerIconFollowUpNone, |
|
133 // attachment icon |
|
134 EViewerAttachment, |
|
135 // used for layouting |
|
136 EViewerIconIndentation, |
|
137 EViewerIconSpacing, |
|
138 // <cmail> |
|
139 EViewerIconSeparatorLine |
|
140 // </cmail> |
|
141 }; |
|
142 |
|
143 // Append given icon type to rich text |
|
144 void UpdateIconL( TViewerIconType aViewerIconType ); |
|
145 |
|
146 // Helpers to get possible current hotpots asked |
|
147 TBool FindCurrentHeaderHotSpotL( SViewerHeadingHotSpotData& aHotSpot ) const; |
|
148 TBool FindCurrentBodyHotSpotL( CFindItemEngine::SFoundItem& aHotSpot ) const; |
|
149 |
|
150 THotspotType FindCurrentHotSpotL( SViewerHeadingHotSpotData& aHeaderHotspot, |
|
151 CFindItemEngine::SFoundItem& aBodyHotspot ) const; |
|
152 |
|
153 // Getters for current hotspot texts |
|
154 HBufC* GetHotspotTextLC( const SViewerHeadingHotSpotData& aCurrentHotSpot ) const; |
|
155 HBufC* GetHotspotTextLC( const CFindItemEngine::SFoundItem& aCurrentHotSpot ) const; |
|
156 HBufC* GetEmailAddressLC( const SViewerHeadingHotSpotData& aCurrentHotSpot ) const; |
|
157 |
|
158 HBufC* GetHeaderHotspotEmailAddressLC( const SViewerHeadingHotSpotData& aCurrentHeaderHotSpotData ) const; |
|
159 |
|
160 // Appending newly fetched text to the end of the body |
|
161 void AppendFetchedBodytextLinesL( CFSMailMessage& aMessagePtr ); |
|
162 |
|
163 // Status layout to show "Fetching More - - -" |
|
164 void CreateStatusLayoutL( TBool aSetEmptyContents = ETrue ); |
|
165 |
|
166 // For fetching updating "Fetching more" -text |
|
167 void AppendFetchingMoreTextL(); |
|
168 void SetEmptyStatusLayoutTextL(); |
|
169 |
|
170 void SetHotspotHighlightedColorL( TInt aStartIndx, TInt aLenght, TBool aHighlight ); |
|
171 |
|
172 TInt CurrentHotspotIndexL(); |
|
173 |
|
174 void SetHotspotByIndexL( TInt aIndex ); |
|
175 |
|
176 TInt EmailStatusIconLine(); |
|
177 TInt FollowupIconLine(); |
|
178 |
|
179 private: |
|
180 |
|
181 // Helper function for getting hotspot text from rich text data |
|
182 HBufC* GetHotspotTextLC( TInt aStartPos, TInt aLength ) const; |
|
183 |
|
184 private: // Methods for constructing the view's rich text |
|
185 |
|
186 // Helper functions for constructing the rich text from the message |
|
187 void AppendRecipientIndetationL(); |
|
188 void AppendNewLineL(); |
|
189 void AppendSpaceL(); |
|
190 void AppendMessageIconL(); |
|
191 TBool AppendFollowUpIconL( CFSMailMessage& aMessagePtr ); |
|
192 void AppendAttachmentIconL(); |
|
193 |
|
194 //<cmail> |
|
195 HBufC* ClipHeaderInfoToFitLC( const TDesC& aText, TBool aIsDisplayName = EFalse ); |
|
196 TInt HeaderIndentedTextAreaWidth( const TBool aAddExtra = ETrue ) const; |
|
197 //</cmail> |
|
198 |
|
199 // These functions read actual data from the message and appends it in the |
|
200 // correct format to the rich text |
|
201 void AppendFromLineL( CFSMailMessage& aMessagePtr, SMailMsgHeaderInfo& aHeaderInfo ); |
|
202 |
|
203 void AppendRecipientLinesL( CFSMailMessage& aMessagePtr, SMailMsgHeaderInfo& aHeaderInfo, |
|
204 TViewerRecipientType aRecipientType ); |
|
205 |
|
206 void AppendSentLineL( CFSMailMessage& aMessagePtr, SMailMsgHeaderInfo& aHeaderInfo ); |
|
207 void AppendSubjectLinesL( CFSMailMessage& aMessagePtr, SMailMsgHeaderInfo& aHeaderInfo ); |
|
208 void AppendAttachmentLinesL( CFSMailMessage& aMessagePtr, SMailMsgHeaderInfo& aHeaderInfo ); |
|
209 void AppendInitialBodytextLinesL( CFSMailMessage& aMessagePtr ); |
|
210 void AppendHtmlTextLineL( CFSMailMessage& aMessagePtr, SMailMsgHeaderInfo& aHeaderInfo ); |
|
211 void AppendRecipientsL( const RPointerArray<CFSMailAddress>& aRecipientArray, SMailMsgHeaderInfo& aHeaderInfo, TViewerRecipientType aRecipientType ); |
|
212 // <cmail> separator line |
|
213 void AppendSeparatorLineL(); |
|
214 TInt SeparatorLineWidth() const; |
|
215 // </cmail> separator line |
|
216 |
|
217 void FindBodyTextHotSpotsL( const TDesC& aBodyContent ); |
|
218 |
|
219 private: // Methods for handling font and layout spesific things. |
|
220 |
|
221 // Different fonts types |
|
222 enum TViewerFontType |
|
223 { |
|
224 EViewerFontTitle = 0, |
|
225 EViewerFontText, |
|
226 EViewerFontBody, |
|
227 EViewerFontHotspotNormal, |
|
228 EViewerFontHotspotHighLighted, |
|
229 EViewerFontSent, |
|
230 EViewerFontIndentation |
|
231 }; |
|
232 |
|
233 //<cmail> |
|
234 // Constructs all used fonts in on array for current text size. |
|
235 //void ReConstructFontArrayL(); |
|
236 |
|
237 // For getting spesific font |
|
238 //CAknLayoutFont& FontFromFontArray( TViewerFontType aFontType ); |
|
239 const CAknLayoutFont* GetCorrectFontL( TViewerFontType aFontType ) const; |
|
240 //</cmail> |
|
241 |
|
242 // For getting different font colors |
|
243 TRgb SkinFontColorByType( TViewerFontType aFontType ); |
|
244 |
|
245 //<cmail> |
|
246 // For constructing different fonts. |
|
247 const CAknLayoutFont* CurrentTitleFontL() const; |
|
248 const CAknLayoutFont* CurrentTextFontL() const; |
|
249 const CAknLayoutFont* CurrentSentTextFontL() const; |
|
250 //</cmail> |
|
251 |
|
252 // Transparent icons are used for layouting purpose. |
|
253 // Only way for setting spesific size of indentations or spaces between |
|
254 // lines in pixels |
|
255 // See LAF documents for more information and for exact sizes. |
|
256 |
|
257 // Different transparent icon types used for layout. |
|
258 enum TViewerSpacingIconType |
|
259 { |
|
260 ETopMostSpace = 0, // top most space in the view before any text |
|
261 ERecipientSpace, // space that is after header info text and actual recipient text |
|
262 EHeaderInfoSpace, // space that is always after recipient text and before next header info text. |
|
263 EBottomMostSpace, // bottom most space in the header after all text |
|
264 ESpaceBetweenIconAndSubject |
|
265 }; |
|
266 |
|
267 // Returns the needed height for the given spacing icon type |
|
268 TInt CurrentSpacingHeight( TViewerSpacingIconType aSpacingIconType ) const; |
|
269 |
|
270 // Appends the given spacig icon type to the rich text |
|
271 void InsertTransparentSpacingIconL( TViewerSpacingIconType aSpacingIconType ); |
|
272 |
|
273 // Append certain size spacing icon after the email status or follow up icon. |
|
274 void InsertSpaceAfterIconL(); |
|
275 |
|
276 // Appends given text with the hotspot font type formating to the rich text as a hotspot |
|
277 void InsertHotspotTextAndFontL( const TDesC& aText ); |
|
278 |
|
279 // Appends given text with the given font type formatting to the rich text |
|
280 void AppendFormattedTextL( const TDesC& aText, TViewerFontType aFontType ); |
|
281 |
|
282 // Inserts given text with the given font type formatting to the given |
|
283 // position in the rich text |
|
284 void InsertFormattedTextL( const TDesC& aText, TViewerFontType aFontType, |
|
285 TInt aPosition ); |
|
286 |
|
287 //<cmail> |
|
288 // Applies formating information to the rich text. |
|
289 void ApplyFontToTextL( const CAknLayoutFont* aFont, TInt aStartInx, |
|
290 TInt aLength, TRgb& aColor, TFontUnderline aUnderline ); |
|
291 //</cmail> |
|
292 |
|
293 // Appends hotspot formating to given body hotspot |
|
294 void AddBodyHotsSpotWithTextFormatingL( const CFindItemEngine::SFoundItem& aBodyHotSpotData ); |
|
295 |
|
296 private: // Construction |
|
297 |
|
298 CFSEmailUiMailViewerRichText( CFreestyleEmailUiAppUi& aFsTextureManager ); |
|
299 |
|
300 void ConstructL(); |
|
301 |
|
302 private: |
|
303 |
|
304 // Text Viewer component's rich text |
|
305 CFsRichText* iViewerRichText; |
|
306 |
|
307 // App Ui handle for getting the texture manager |
|
308 CFreestyleEmailUiAppUi& iAppUi; |
|
309 |
|
310 // Mail message pointer, changes always in do activate |
|
311 CFsTextViewer* iTextViewer; // not owned |
|
312 // Used to display Fetching more Text |
|
313 CAlfTextVisual* iStatusVisual; // not owned |
|
314 |
|
315 // Used to display Fetching more Text |
|
316 CAlfAnchorLayout* iStatusLayout; // not owned |
|
317 |
|
318 CFSMailMessage* iMessage; // not owned |
|
319 CFSMailBox* iMailBox; // not owned |
|
320 |
|
321 // Header data storage |
|
322 SMailMsgHeaderInfo iHeaderLineInfo; |
|
323 |
|
324 // Header and body hotspot arrays |
|
325 RArray<SViewerHeadingHotSpotData> iViewerHeadingHotSpotData; |
|
326 RArray<CFindItemEngine::SFoundItem> iBodyTextHotSpotData; |
|
327 |
|
328 // Total length of the header text after the text has been constructed |
|
329 TInt iHeaderLength; |
|
330 |
|
331 // Helper variable to store current document lenght while constructing rich text |
|
332 TInt iRichTextDocumentLength; |
|
333 |
|
334 // Amount of characters currently shown from the body part |
|
335 TInt iBodyLength; |
|
336 |
|
337 // Autofetch animation ellipsis count |
|
338 TInt iCurrentEllipsisCount; |
|
339 |
|
340 // Array fonts |
|
341 RPointerArray<CAknLayoutFont> iFontsArray; |
|
342 |
|
343 // Size of the next spacing icon to be drawn. |
|
344 TSize iCurrentSpacingIconSize; |
|
345 |
|
346 // Icon places |
|
347 TInt iEmailStatusIconPlace; |
|
348 TInt iEmailStatusIconLine; |
|
349 TInt iFollowupIconPlace; |
|
350 TInt iFollowupIconLine; |
|
351 TInt iAttachmentIconPlace; |
|
352 |
|
353 // Lines and hotsopt indicies for initial scrolling position handling |
|
354 TInt iSentTextLine; |
|
355 TInt iSubjectTextLine; |
|
356 TInt iAttachmentHotSpotIndex; |
|
357 TInt iViewHtmlHotSpotIndex; |
|
358 }; |
|
359 |
|
360 #endif //__FREESTYLEEMAILUI_MAILVIEWERRICHTEXT_H__ |
|