|
1 /* |
|
2 * Copyright (c) 2007-2008 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: richtext container |
|
15 * Description : Handles statuspane, context pane, navi pane |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef _CIMCVAPPRICHTEXTCONTAINER_H |
|
21 #define _CIMCVAPPRICHTEXTCONTAINER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "mimcvenginemessagecontainer.h" |
|
25 #include "mimcvapplayoutchangeobserver.h" |
|
26 #include "mimcvappresourcechangeobserver.h" |
|
27 #include <gulicon.h> |
|
28 #include <e32base.h> |
|
29 #include <e32std.h> |
|
30 #include <frmtlay.h> // TCursorSelection |
|
31 |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CIMCVAppMessageWrapper; |
|
35 class CParaFormatLayer; |
|
36 class CCharFormatLayer; |
|
37 class CRichText; |
|
38 class MLayDoc; |
|
39 class MIMCVAppTextView; |
|
40 class CIMCVAppMessageExtensionsHandler; |
|
41 class MIMCVAppUi; |
|
42 class MIMCVAppResourceChangeObserver; |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * Rich text container |
|
47 * @since Series 60 5.0 |
|
48 */ |
|
49 class CIMCVAppRichTextContainer : public CBase, |
|
50 public MIMCVEngineMessageContainer, |
|
51 public MIMCVAppLayoutChangeObserver, |
|
52 public MIMCVAppResourceChangeObserver |
|
53 { |
|
54 public: // enumerations |
|
55 enum THighlightMovement |
|
56 { |
|
57 ENext = 0, |
|
58 EPrevious |
|
59 }; |
|
60 |
|
61 static CGulIcon*& iTempIcon; |
|
62 |
|
63 |
|
64 private: // enums |
|
65 |
|
66 enum THighlightState |
|
67 { |
|
68 ENoHighlight = 0, |
|
69 EItemSelected, |
|
70 EMessageTop, |
|
71 EMessageBottom |
|
72 }; |
|
73 public: // Constructors and destructor |
|
74 |
|
75 /** |
|
76 * Two-phased constructor. |
|
77 * @param aTextView Viewer of the text |
|
78 * @param aExtensionsHandler Message extensions handler |
|
79 * @param aMessageUtils Message utils |
|
80 * @param aScrollOver Should we scroll over the top and bottom, |
|
81 * i.e. disabling highlight when pressing up at top. |
|
82 * @param aPrimaryKey primary key of the object - used for storage and searching |
|
83 */ |
|
84 static CIMCVAppRichTextContainer* NewL(MIMCVAppUi* aAppUi, |
|
85 MIMCVAppTextView* aTextView, |
|
86 CIMCVAppMessageExtensionsHandler* aExtensionsHandler, |
|
87 CGulIcon* aFromMe, |
|
88 CGulIcon* aToMe, |
|
89 MGraphicsDeviceMap* aMap, |
|
90 const TDesC& aPrimaryKey, |
|
91 TInt aServiceId, |
|
92 TBool aScrollOver /*= ETrue*/ |
|
93 ); |
|
94 |
|
95 /** |
|
96 * Destructor. |
|
97 */ |
|
98 virtual ~CIMCVAppRichTextContainer(); |
|
99 |
|
100 public: // From MIMCVAppResourceChangeObserver |
|
101 |
|
102 /** |
|
103 * Reload all icons on resource change |
|
104 */ |
|
105 void ResourceChangedL(); |
|
106 public: // New functions |
|
107 |
|
108 |
|
109 /** |
|
110 * @return Buffer containing the currently selected text |
|
111 * (or empty buffer if nothing selected) |
|
112 */ |
|
113 HBufC* SelectedItemL(); |
|
114 |
|
115 /** |
|
116 * @return Type of selected item |
|
117 */ |
|
118 TInt SelectedItemType(); |
|
119 |
|
120 /** |
|
121 * @return Text layout interface for displaying the text |
|
122 */ |
|
123 MLayDoc* TextLayout(); |
|
124 |
|
125 /** |
|
126 * Moves current highlight selection |
|
127 * @return KErrNotFound If there are no items to highlight. |
|
128 * KErrNone otherwise. |
|
129 */ |
|
130 TInt MoveHighlightL( THighlightMovement aDirection ); |
|
131 |
|
132 /** |
|
133 * Set all highlighting off |
|
134 */ |
|
135 void DisableHighlightL(); |
|
136 |
|
137 |
|
138 /** |
|
139 * @return ETrue if some item is highlighted |
|
140 */ |
|
141 TBool Highlighted(); |
|
142 |
|
143 /** |
|
144 * Highlights whole message or item at given position. |
|
145 * @param aPos Highlights the message or item which has |
|
146 * the craracter at aPos |
|
147 * @return KErrNone - if highlighted a new item |
|
148 * KErrAlreadyExists - if item is already highlighted |
|
149 * KErrNotFound - if can't find message or item at aPos |
|
150 */ |
|
151 TInt HighlightItemAtPosL( TInt aPos ); |
|
152 |
|
153 |
|
154 /** |
|
155 * @returns the total messages in the view |
|
156 */ |
|
157 TInt GetMessageCount(); |
|
158 |
|
159 /** |
|
160 * Sets item highlight on or off |
|
161 * @param aItemHighlight ETrue if the items inside messages |
|
162 * should be highlighted |
|
163 */ |
|
164 void SetItemHighlight( TBool aItemHighlight ); |
|
165 |
|
166 public: // From MIMCVAppLayoutChangeObserver |
|
167 |
|
168 /** |
|
169 * From MIMCVAppLayoutChangeObserver |
|
170 */ |
|
171 void LayoutChangedL( TInt aType ); |
|
172 |
|
173 public: |
|
174 /** |
|
175 * Returns the Primary key of the object |
|
176 */ |
|
177 const TDesC& GetPrimaryKey(); |
|
178 |
|
179 /** |
|
180 * Updates the color of messages according to current skin. |
|
181 * Only the theme colored part of messages are updated. |
|
182 * This method should be called when the skin is changed. |
|
183 * @return None |
|
184 */ |
|
185 void UpdateSkinnedTextColourL(); |
|
186 |
|
187 protected: // Functions from MIMCVEngineMessageContainer |
|
188 |
|
189 /** |
|
190 * Add new message to container |
|
191 * @param aMessage Message |
|
192 */ |
|
193 void AddMessageL( MIMCVEngineMessage& aMessage ); |
|
194 |
|
195 |
|
196 /** |
|
197 * @see MIMCVEngineMessageContainer |
|
198 */ |
|
199 void InsertMessageL( MIMCVEngineMessage& aMessage ); |
|
200 |
|
201 protected: // New functions |
|
202 |
|
203 /** |
|
204 * Updates all wrappers after (and including) aFirstIndex |
|
205 * Adds aChange to wrapper positions (in rich text) |
|
206 * @param aFirstIndex Index of first modified wrapper |
|
207 * @param aChange Removed or added number of characters in rich |
|
208 * text before wrapper at aFirstIndex |
|
209 */ |
|
210 void UpdateWrappers( TInt aFirstIndex, TInt aChange ); |
|
211 |
|
212 /** |
|
213 * @return Union of two selections |
|
214 * @param aSel1, cursor selection position1 |
|
215 * @param aSel2, cursor selection position2 |
|
216 */ |
|
217 TCursorSelection Union( const TCursorSelection& aSel1, |
|
218 const TCursorSelection& aSel2 ); |
|
219 |
|
220 /** |
|
221 * @return Currently highlighted selection, or last |
|
222 * message if highlighting is disabled |
|
223 */ |
|
224 TCursorSelection CurrentSelection() const; |
|
225 |
|
226 /** |
|
227 * Sets the background color of selected text |
|
228 * @param aSel, cursor selection position |
|
229 * @param aColor, color to use |
|
230 */ |
|
231 void TextBackColorL( const TCursorSelection& aSel, const TRgb& aColor ); |
|
232 |
|
233 /** |
|
234 * Sets the color of selected text |
|
235 * @param aSel, cursor selection position |
|
236 * @param aColor, color to use |
|
237 */ |
|
238 void TextColorL( const TCursorSelection& aSel, const TRgb& aColor ); |
|
239 |
|
240 /** |
|
241 * Sets the background color of selected paragraph |
|
242 * @param aSel, cursor selection position |
|
243 * @param aColor, color to use |
|
244 */ |
|
245 void BackColorL( const TCursorSelection& aSel, const TRgb& aColor ); |
|
246 |
|
247 /** |
|
248 * Format the highlight item |
|
249 * @param aSel, cursor selection position |
|
250 */ |
|
251 void HighLightItemL( const TCursorSelection& aSel ); |
|
252 |
|
253 /** |
|
254 * Sets the selection bold |
|
255 * @param aSel, cursor selection position |
|
256 */ |
|
257 void BoldL( const TCursorSelection& aSel ); |
|
258 |
|
259 /** |
|
260 * Parses text for highlight items (phone numbers, urls) and places |
|
261 * the positions to messagewrapper. |
|
262 * @param aText Text to be parsed |
|
263 * @param aStartPos Start position of aText in rich text |
|
264 * @param aRelativePos Relative position of aText inside one message |
|
265 * @param aMessageWrapper Message wrapper where positions are stored |
|
266 */ |
|
267 void ParseTextL( const TDesC& aText, TInt aStartPos, TInt aRelativePos, |
|
268 CIMCVAppMessageWrapper& aMessageWrapper ); |
|
269 |
|
270 /** |
|
271 * Add nickname of a message to rich text |
|
272 * @param aMessageWrapper Message wrapper |
|
273 * @return Selection for nickname (for coloring) |
|
274 */ |
|
275 TCursorSelection AddNickL( CIMCVAppMessageWrapper& aMessageWrapper ); |
|
276 |
|
277 /** |
|
278 * Add timestamp of a message to rich text |
|
279 * @param aMessageWrapper Message wrapper |
|
280 * @return Selection of timestamp |
|
281 */ |
|
282 TCursorSelection AddTimeStampL( CIMCVAppMessageWrapper& aMessageWrapper ); |
|
283 |
|
284 /** |
|
285 * Add content of a message to rich text |
|
286 * @param aMsgStart Start position of this message in rich text |
|
287 * @param aMessageWrapper Message wrapper |
|
288 */ |
|
289 void AddContentL( TInt aMsgStart, CIMCVAppMessageWrapper& aMessageWrapper ); |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 /** |
|
295 * Helper method to determine which part of the message really is |
|
296 * colored by the active skin. |
|
297 * @param aMessageWrapper Message to inspect |
|
298 * @param aUseDefaultColors Variation for default colours |
|
299 * @param aCustomDefinedColor Has user customized the message colour |
|
300 * @return Selection of the text which follows the skin color |
|
301 */ |
|
302 TCursorSelection SkinColoredSelection( |
|
303 CIMCVAppMessageWrapper& aMessageWrapper, |
|
304 TBool aUseDefaultColors, |
|
305 TBool aCustomDefinedColor ); |
|
306 |
|
307 /** |
|
308 * Helper method for replacing all paragraph delimiters |
|
309 * inside message content with line breaks, needed for |
|
310 * keeping text alignment consistent inside one message. |
|
311 * Used in AddContentL. |
|
312 * @since S60 v5.0 |
|
313 * @param aSource Source descriptor. |
|
314 * @param aTarget Target descriptor. Caller is responsible |
|
315 * to provide a large enough descriptor, |
|
316 * aTarget size must not be less than |
|
317 * size of aSource. |
|
318 */ |
|
319 void ReplaceParaDelimsWithLineBreaks( |
|
320 const TPtrC& aSource, |
|
321 TPtr& aTarget ) const; |
|
322 |
|
323 /** |
|
324 * Helper method to update selection inside rich text. |
|
325 * This will remove the highlight from previously selected item |
|
326 * and add highlight to newly selected item. |
|
327 * @since S60 v5.0 |
|
328 */ |
|
329 void UpdateSelectionL(); |
|
330 |
|
331 /** |
|
332 * Insert nickname of a message to rich text start. |
|
333 * @param aMessageWrapper Message wrapper. |
|
334 * @return Selection for nickname. |
|
335 */ |
|
336 TCursorSelection InsertNickL( CIMCVAppMessageWrapper& aMessageWrapper ); |
|
337 |
|
338 /** |
|
339 * Insert timestamp of a message to rich text. |
|
340 * @param aMessageWrapper Message wrapper. |
|
341 * @return Selection of timestamp. |
|
342 */ |
|
343 TCursorSelection InsertTimeStampL( CIMCVAppMessageWrapper& aMessageWrapper ); |
|
344 |
|
345 /** |
|
346 * Insert content of a message to rich text. |
|
347 * @param aMessageWrapper Message wrapper. |
|
348 * @return Length of content added. |
|
349 */ |
|
350 TInt InsertContentL( CIMCVAppMessageWrapper& aMessageWrapper ); |
|
351 |
|
352 public: |
|
353 /** |
|
354 * Initializes the object with its cintainer's object |
|
355 * @param aTextView - container object |
|
356 */ |
|
357 void Initialize( MIMCVAppUi* aAppUi, |
|
358 MIMCVAppTextView* aTextView, |
|
359 CIMCVAppMessageExtensionsHandler* aExtensionsHandler, |
|
360 CGulIcon* aFromMe, |
|
361 CGulIcon* aToMe, |
|
362 MGraphicsDeviceMap* aMap, |
|
363 TBool aScrollOver /*= ETrue*/); |
|
364 |
|
365 TInt ServiceId() const; |
|
366 |
|
367 |
|
368 private: |
|
369 |
|
370 /** |
|
371 * constructor. |
|
372 * @param aTextView Viewer of the text |
|
373 * @param aExtensionsHandler Message extensions handler |
|
374 * @param aMessageUtils Message utils |
|
375 * @param aScrollOver Should we scroll over the top and bottom, |
|
376 * i.e. disabling highlight when pressing up at top. |
|
377 */ |
|
378 CIMCVAppRichTextContainer( MIMCVAppUi* aAppUi, |
|
379 MIMCVAppTextView* aTextView, |
|
380 CIMCVAppMessageExtensionsHandler* aExtensionsHandler, |
|
381 CGulIcon* aFromMe, |
|
382 CGulIcon* aToMe, |
|
383 MGraphicsDeviceMap* aMap, |
|
384 TInt aServiceId, |
|
385 TBool aScrollOver /*= ETrue*/ ); |
|
386 |
|
387 /** |
|
388 * By default Symbian 2nd phase constructor is private. |
|
389 * @ params aPrimaryKey - primary key of the object |
|
390 */ |
|
391 void ConstructL(const TDesC& aPrimaryKey); |
|
392 |
|
393 CGulIcon* LoadDefaultBitmapL( TInt aBitmapId, TInt aMaskId, |
|
394 const TDesC& aFullPath, TBool aOverrideBrand = EFalse) ; |
|
395 |
|
396 private: // Data |
|
397 |
|
398 MIMCVAppUi* iAppUi; |
|
399 // doesn't own, interface to text viewer |
|
400 MIMCVAppTextView* iTextView; |
|
401 |
|
402 // item highlight |
|
403 TBool iItemHighlight; |
|
404 // current highlight state |
|
405 THighlightState iHighlightState; |
|
406 // message extensions handler |
|
407 CIMCVAppMessageExtensionsHandler* iExtensionsHandler; |
|
408 |
|
409 // Should we scroll over the top and bottom, |
|
410 // i.e. disabling highlight when pressing up at top. |
|
411 TBool iScrollOver; |
|
412 |
|
413 // Owns. Paragraph formatter |
|
414 CParaFormatLayer* iParaFormatLayer; |
|
415 |
|
416 // Owns. Character formatter |
|
417 CCharFormatLayer* iCharFormatLayer; |
|
418 |
|
419 // Owns. rich text document |
|
420 CRichText* iRichText; |
|
421 |
|
422 // Owns. message wrappers |
|
423 RPointerArray<CIMCVAppMessageWrapper> iMessages; |
|
424 |
|
425 // selected message |
|
426 TInt iSelected; |
|
427 |
|
428 // selected item in message |
|
429 TInt iSelectedItem; |
|
430 // previous selection |
|
431 TCursorSelection iPrevious; |
|
432 |
|
433 // should whole message be colored |
|
434 TBool iColorWholeMessage; |
|
435 // alternative colors |
|
436 TBool iOwnMsgColorInUse; |
|
437 TRgb iOwnMsgColor; |
|
438 TBool iMsgColorInUse; |
|
439 TRgb iMsgColor; |
|
440 |
|
441 // Show timestamp setting value |
|
442 TBool iShowTimeStamps; |
|
443 |
|
444 |
|
445 // doesn't own |
|
446 const CFont* iPrimaryFont; |
|
447 const CFont* iSecondaryFont; |
|
448 |
|
449 // "From me" icon. Not owned. |
|
450 // Pointer to a pointer because this can change |
|
451 CGulIcon* iFromMe; |
|
452 |
|
453 // "To me" icon. Not owned. |
|
454 // Pointer to a pointer because this can change |
|
455 CGulIcon* iToMe; |
|
456 |
|
457 |
|
458 // interface to graphics device for converting pixels to twips |
|
459 MGraphicsDeviceMap* iMap; |
|
460 |
|
461 //Owns Primary key - Used while storing the object |
|
462 HBufC* iPrimaryKey; |
|
463 |
|
464 // service Id |
|
465 TInt iServiceId; |
|
466 |
|
467 }; |
|
468 |
|
469 #endif // _CIMCVAPPRICHTEXTCONTAINER_H |
|
470 |
|
471 // End of File |