|
1 /* |
|
2 * Copyright (c) 2003-2009 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 : CEikRichTextEditor based Rich Text viewer |
|
15 * Version : %version: tr1sido#4.1.4 % |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef CESMRRICHTEXTVIEWER_H |
|
20 #define CESMRRICHTEXTVIEWER_H |
|
21 |
|
22 #include <eikrted.h> |
|
23 #include <cntitem.h> |
|
24 #include <eikcmobs.h> |
|
25 #include <aknlongtapdetector.h> |
|
26 |
|
27 #include "resmrstatic.h" |
|
28 |
|
29 class CESMRRichTextLink; |
|
30 class CESMRLayoutManager; |
|
31 class MESMRFieldEventQueue; |
|
32 |
|
33 // SCROLLING_MOD: List observer forward declaraion |
|
34 class MESMRListObserver; |
|
35 |
|
36 /* |
|
37 * Pure virtual link selection observer. |
|
38 */ |
|
39 class MESMRRichTextObserver |
|
40 { |
|
41 public: |
|
42 /* |
|
43 * CESMRichTextViewer calls this function with selected link before |
|
44 * showing Contact Action Menu. If observer handles link selection it |
|
45 * should return ETrue, in which case CESMRRichTextViewer won't handle |
|
46 * it. |
|
47 */ |
|
48 virtual TBool |
|
49 HandleRichTextLinkSelection(const CESMRRichTextLink* aLink ) = 0; |
|
50 }; |
|
51 |
|
52 /* |
|
53 * CEikRichTextEditor based Rich Text viewer. |
|
54 */ |
|
55 NONSHARABLE_CLASS( CESMRRichTextViewer ) : public CEikRichTextEditor, |
|
56 public MEikCommandObserver, |
|
57 public MAknLongTapDetectorCallBack |
|
58 { |
|
59 public: |
|
60 /* |
|
61 * Two-phase constructor. |
|
62 * @param aParent if aParent is NULL, |
|
63 * CEikRichTextEditor is constucted as |
|
64 * window owning control. |
|
65 * @return Created object |
|
66 */ |
|
67 IMPORT_C static CESMRRichTextViewer* NewL( |
|
68 const CCoeControl* aParent = NULL); |
|
69 |
|
70 /* |
|
71 * Destructor. |
|
72 */ |
|
73 IMPORT_C ~CESMRRichTextViewer( ); |
|
74 |
|
75 // From CCoeControl |
|
76 IMPORT_C void PositionChanged( ); |
|
77 IMPORT_C void FocusChanged( TDrawNow aDrawNow ); |
|
78 IMPORT_C TKeyResponse OfferKeyEventL( |
|
79 const TKeyEvent &aKeyEvent, |
|
80 TEventCode aType ); |
|
81 |
|
82 IMPORT_C void SetMargins( TInt sMargin ); |
|
83 |
|
84 IMPORT_C void SetFontL( |
|
85 const CFont* aFont, |
|
86 CESMRLayoutManager* aLayout = NULL ); |
|
87 |
|
88 /* |
|
89 * Sets CEikRichTextEditor's text and searches text for emails, |
|
90 * phone numbers and urls if aSearchLinks is set to ETrue. |
|
91 * |
|
92 * @param aText text to be set for CEikRichTextEditor |
|
93 * @param aSearchLinks search emails, phone numbers and urls |
|
94 */ |
|
95 IMPORT_C void SetTextL(const TDesC* aText, TBool aSearchLinks = EFalse ); |
|
96 |
|
97 /* |
|
98 * Sets observer for link selections. |
|
99 * @param aLinkObserver pointer to observer object |
|
100 */ |
|
101 IMPORT_C void SetLinkObserver(MESMRRichTextObserver* aLinkObserver); |
|
102 |
|
103 /* |
|
104 * Adds link to text. |
|
105 * @param aLink link to be added |
|
106 */ |
|
107 IMPORT_C void AddLinkL(CESMRRichTextLink* aLink ); |
|
108 |
|
109 /** |
|
110 * Inserts link to text. |
|
111 * @param aLink link to be added |
|
112 * @param aPosition position where link is added |
|
113 */ |
|
114 IMPORT_C void InsertLinkL( CESMRRichTextLink* aLink, TInt aPosition ); |
|
115 |
|
116 /* |
|
117 * Returns selected link, or NULL if none selected. |
|
118 */ |
|
119 IMPORT_C const CESMRRichTextLink* GetSelectedLink( ) const; |
|
120 |
|
121 /* |
|
122 * Returns text for selected link from underlying CEikRichTextViewer. |
|
123 * |
|
124 * @param aLink link |
|
125 */ |
|
126 IMPORT_C HBufC* GetLinkTextL( const CESMRRichTextLink& aLink ) const; |
|
127 |
|
128 /* |
|
129 * Returns pointer to new CContactItem constructed from aLink. |
|
130 * Function uses CESMRRichTextLink::Value to create contact |
|
131 * with CESMRRichTextLink::Type information. |
|
132 * |
|
133 * @param aLink link |
|
134 */ |
|
135 IMPORT_C CContactItem* CreateContactItemL( const CESMRRichTextLink& aLink ); |
|
136 |
|
137 |
|
138 /* |
|
139 * Method for cesmrviewerdescriptionfield to set the list observer |
|
140 * |
|
141 * @param aObserver observer that should be notified |
|
142 */ |
|
143 IMPORT_C void SetListObserver( MESMRListObserver* aObserver ); |
|
144 |
|
145 /** |
|
146 * Returns height of one row. |
|
147 * |
|
148 * @return row's height |
|
149 */ |
|
150 IMPORT_C TInt RowHeight(); |
|
151 /** |
|
152 * Returns text line count. |
|
153 * |
|
154 * @return line count |
|
155 */ |
|
156 IMPORT_C TInt LineCount(); |
|
157 /** |
|
158 * Returns line number of currenly |
|
159 * focused row starting from one. |
|
160 * |
|
161 * @return row's height |
|
162 */ |
|
163 IMPORT_C TInt CurrentLineNumber(); |
|
164 |
|
165 /** |
|
166 * Enables and disables action menu |
|
167 * @param aStatus Enables or disables action menu |
|
168 */ |
|
169 IMPORT_C void SetActionMenuStatus( TBool aStatus ); |
|
170 |
|
171 /** |
|
172 * Copies currently selected richtext link associated with |
|
173 * action menu to the clipboard |
|
174 */ |
|
175 IMPORT_C void CopyCurrentLinkToClipBoardL() const; |
|
176 |
|
177 /** |
|
178 * Copies currently link value to clipboard |
|
179 * action menu to the clipboard |
|
180 */ |
|
181 IMPORT_C void CopyCurrentLinkValueToClipBoardL() const; |
|
182 |
|
183 /** |
|
184 * convenience method to reset TLS static contactactionmenuhandler |
|
185 * for classes that only have access to richtextviewer. |
|
186 * Needed for richtextviewer fields when they lose focus. |
|
187 */ |
|
188 IMPORT_C void ResetActionMenuL() const; |
|
189 |
|
190 /** |
|
191 * Sets event queue for field. Observer can be used |
|
192 * for triggering commands and notifying events. |
|
193 * @param aEventObserver the event observer |
|
194 */ |
|
195 IMPORT_C void SetEventQueue( MESMRFieldEventQueue* aEventQueue ); |
|
196 |
|
197 /** |
|
198 * Selects current link. |
|
199 * @return ETrue if link selected |
|
200 */ |
|
201 IMPORT_C TBool LinkSelectedL(); |
|
202 |
|
203 protected: // From MEikCommandObserver |
|
204 |
|
205 /** |
|
206 * Process commands from contact menu handler. |
|
207 * Forwards commands to event observer. |
|
208 */ |
|
209 void ProcessCommandL( TInt aCommandId ); |
|
210 |
|
211 protected: // From MAknLongTapDetectorCallBack |
|
212 virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, |
|
213 const TPoint& aPenEventScreenLocation ); |
|
214 |
|
215 protected: // From CEikEdwin |
|
216 /** |
|
217 * Sets the control as ready to be drawn. |
|
218 */ |
|
219 void ActivateL(); |
|
220 |
|
221 protected: // From CCoeControl |
|
222 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
223 |
|
224 private: |
|
225 /* |
|
226 * Private constuctor. |
|
227 */ |
|
228 CESMRRichTextViewer( ); |
|
229 |
|
230 /* |
|
231 * Two-phase constructor. |
|
232 * @param aParent if aParent is NULL, CEikRichTextEditor |
|
233 * is constucted as window owning control. |
|
234 */ |
|
235 void ConstructL(const CCoeControl* aParent ); |
|
236 |
|
237 /* |
|
238 * CCoeControl::Draw is overridden. |
|
239 */ |
|
240 void Draw( const TRect& aRect ) const; |
|
241 |
|
242 /* |
|
243 * Draws right-click icon. |
|
244 * @param aLink link to which draw icon |
|
245 */ |
|
246 void DrawRightClickIconL(const CESMRRichTextLink& aLink) const; |
|
247 |
|
248 /* |
|
249 * Highlights link in CEikRichTextEditor. |
|
250 * |
|
251 * @param aLink link to be highlighted |
|
252 */ |
|
253 void HighlightLink(const CESMRRichTextLink& aLink ); |
|
254 |
|
255 /* |
|
256 * Private internal function which searches for emails, |
|
257 * phone numbers and urls from given text using CFindItemEngine. |
|
258 * |
|
259 * @param aText text which is shown in CEikRichTextEditor |
|
260 */ |
|
261 void SearchLinksL(const TDesC& aText ); |
|
262 |
|
263 void ScrollViewL( |
|
264 TInt aNumberOfRows, |
|
265 TCursorPosition::TMovementType aDirection); |
|
266 TInt FindTextLinkBetweenNextScrollArea( |
|
267 TInt aStartRow, |
|
268 TInt aEndRow, |
|
269 TCursorPosition::TMovementType aDirection); |
|
270 |
|
271 TBool SetHighLightToNextLinkL( TCursorPosition::TMovementType aDirection, |
|
272 TInt aStartRow, |
|
273 TInt aEndRow); |
|
274 TInt ValidLinkForFocusing( TInt aIndex, |
|
275 TCursorPosition::TMovementType aDirection, |
|
276 TInt aStartRow, |
|
277 TInt aEndRow); |
|
278 |
|
279 void SetFontColorL( TBool aFocused = EFalse ); |
|
280 |
|
281 void SetValueL( const CESMRRichTextLink& aLink ); |
|
282 |
|
283 private: // Data |
|
284 /// Own: |
|
285 TInt iCurrentLinkIndex; |
|
286 /// Own: |
|
287 RPointerArray<CESMRRichTextLink> iLinkList; |
|
288 /// Ref: |
|
289 MESMRRichTextObserver* iLinkObserver; |
|
290 /// Own: |
|
291 RESMRStatic iESMRStatic; |
|
292 /// Own: |
|
293 CFbsBitmap* iActionMenuIcon; |
|
294 /// Own: |
|
295 CFbsBitmap* iActionMenuIconMask; |
|
296 /// Ref: |
|
297 MESMRListObserver* iObserver; |
|
298 /// Own: |
|
299 TInt iNumberOfLines; |
|
300 /// Own: |
|
301 TInt iApproximatelyRowHeight; |
|
302 /// Ref: pointer to font |
|
303 const CFont* iFont; |
|
304 /// Ref: Pointer to layout manager |
|
305 CESMRLayoutManager* iLayout; |
|
306 /// Ref: Contact Menu handler |
|
307 CESMRContactMenuHandler* iCntMenuHdlr; |
|
308 /// Ref: Pointer to event queue |
|
309 MESMRFieldEventQueue* iEventQueue; |
|
310 /// Own: Flag for action menu status |
|
311 TBool iActionMenuStatus; |
|
312 /// Own: |
|
313 TCharFormat iFormat; |
|
314 /// Own: |
|
315 TCharFormatMask iFormatMask; |
|
316 // Own: |
|
317 CAknLongTapDetector* iLongTapDetector; |
|
318 // Indicates is action menu opened |
|
319 TBool iActionMenuOpen; |
|
320 }; |
|
321 |
|
322 #endif /*CESMRRICHTEXTVIEWER_H*/ |