18 #include "cesmrviewerfromfield.h" |
18 #include "cesmrviewerfromfield.h" |
19 #include "cesmrrichtextviewer.h" |
19 #include "cesmrrichtextviewer.h" |
20 #include "cesmrrichtextlink.h" |
20 #include "cesmrrichtextlink.h" |
21 #include "mesmrlistobserver.h" |
21 #include "mesmrlistobserver.h" |
22 #include "esmrfieldbuilderdef.h" |
22 #include "esmrfieldbuilderdef.h" |
23 #include "cesmrlayoutmgr.h" |
|
24 #include "nmrlayoutmanager.h" |
23 #include "nmrlayoutmanager.h" |
25 #include "cmrlabel.h" |
24 #include "cmrlabel.h" |
26 |
25 |
27 #include <calentry.h> |
26 #include <calentry.h> |
28 #include <caluser.h> |
27 #include <caluser.h> |
29 #include <StringLoader.h> |
28 #include <stringloader.h> |
30 #include <eikenv.h> |
29 #include <eikenv.h> |
31 #include <avkon.hrh> |
30 #include <avkon.hrh> |
32 #include <AknUtils.h> |
31 #include <aknutils.h> |
33 #include <esmrgui.rsg> |
32 #include <esmrgui.rsg> |
34 |
33 |
35 // DEBUG |
34 // DEBUG |
36 #include "emailtrace.h" |
35 #include "emailtrace.h" |
37 |
36 |
38 /// Unnamed namespace for local definitions |
|
39 namespace { // codescanner::namespace |
|
40 |
|
41 const TInt KMargin = 5; |
|
42 |
|
43 } // namespace |
|
44 |
|
45 using namespace ESMRLayout; |
|
46 |
37 |
47 // ======== MEMBER FUNCTIONS ======== |
38 // ======== MEMBER FUNCTIONS ======== |
48 |
39 |
49 // --------------------------------------------------------------------------- |
40 // --------------------------------------------------------------------------- |
50 // CESMRViewerFromField::NewL() |
41 // CESMRViewerFromField::NewL() |
66 // |
57 // |
67 CESMRViewerFromField::~CESMRViewerFromField( ) |
58 CESMRViewerFromField::~CESMRViewerFromField( ) |
68 { |
59 { |
69 FUNC_LOG; |
60 FUNC_LOG; |
70 delete iFieldTopic; |
61 delete iFieldTopic; |
71 delete iRichTextViewer; |
|
72 } |
62 } |
73 |
63 |
74 // --------------------------------------------------------------------------- |
64 // --------------------------------------------------------------------------- |
75 // CESMRViewerFromField::InitializeL() |
65 // CESMRViewerFromField::InitializeL() |
76 // --------------------------------------------------------------------------- |
66 // --------------------------------------------------------------------------- |
77 // |
67 // |
78 void CESMRViewerFromField::InitializeL() |
68 void CESMRViewerFromField::InitializeL() |
79 { |
69 { |
80 FUNC_LOG; |
70 FUNC_LOG; |
81 TAknLayoutText editorRect = |
71 TAknLayoutText editorRect = |
82 NMRLayoutManager::GetLayoutText( |
72 NMRLayoutManager::GetLayoutText( |
83 Rect(), NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
73 Rect(), NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
84 iRichTextViewer->SetFontL( editorRect.Font(), iLayout ); |
74 iRichTextViewer->SetFontL( editorRect.Font() ); |
85 const CFont* topicFont = |
75 iRichTextViewer->ApplyLayoutChangesL(); |
|
76 |
|
77 const CFont* topicFont = |
86 AknLayoutUtils::FontFromId( EAknLogicalFontPrimaryFont, NULL ); |
78 AknLayoutUtils::FontFromId( EAknLogicalFontPrimaryFont, NULL ); |
87 iFieldTopic->SetFont( topicFont ); |
79 iFieldTopic->SetFont( topicFont ); |
|
80 iRichTextViewer->SetEventQueue( iEventQueue ); |
88 } |
81 } |
89 |
82 |
90 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
91 // CESMRViewerFromField::InternalizeL() |
84 // CESMRViewerFromField::InternalizeL() |
92 // --------------------------------------------------------------------------- |
85 // --------------------------------------------------------------------------- |
135 // |
126 // |
136 void CESMRViewerFromField::SizeChanged( ) |
127 void CESMRViewerFromField::SizeChanged( ) |
137 { |
128 { |
138 FUNC_LOG; |
129 FUNC_LOG; |
139 TRect rect( Rect() ); |
130 TRect rect( Rect() ); |
140 |
131 |
141 TAknLayoutRect row1LayoutRect = |
132 TAknLayoutRect row1LayoutRect = |
142 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
133 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
143 rect = row1LayoutRect.Rect(); |
134 rect = row1LayoutRect.Rect(); |
144 |
135 |
145 TAknTextComponentLayout labelLayout = |
136 TAknTextComponentLayout labelLayout = |
146 NMRLayoutManager::GetTextComponentLayout( |
137 NMRLayoutManager::GetTextComponentLayout( |
147 NMRLayoutManager::EMRTextLayoutText ); |
138 NMRLayoutManager::EMRTextLayoutText ); |
148 AknLayoutUtils::LayoutLabel( iFieldTopic, rect, labelLayout ); |
139 AknLayoutUtils::LayoutLabel( iFieldTopic, rect, labelLayout ); |
149 // Color should be overrided after layouting |
|
150 // If this function leaves we'll have to use default color |
|
151 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
152 *iFieldTopic, |
|
153 EColorLabelText, |
|
154 KRgbBlack )); |
|
155 |
140 |
156 rect = Rect(); |
141 rect = Rect(); |
157 TAknLayoutRect row2LayoutRect = |
142 TAknLayoutRect row2LayoutRect = |
158 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
143 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
159 rect = row2LayoutRect.Rect(); |
144 rect = row2LayoutRect.Rect(); |
160 |
145 |
161 // Move the iY down the height of the title field |
146 // Move the iY down the height of the title field |
162 TInt moveHeight = row1LayoutRect.Rect().Height(); |
147 TInt moveHeight = row1LayoutRect.Rect().Height(); |
163 rect.Move( 0, moveHeight ); |
148 rect.Move( 0, moveHeight ); |
164 |
149 |
165 TAknLayoutText editorRect = |
150 TAknLayoutText editorRect = |
166 NMRLayoutManager::GetLayoutText( |
151 NMRLayoutManager::GetLayoutText( |
167 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
152 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
168 // Count the rect for the richtextviewer. It will be placed into the |
153 // Count the rect for the richtextviewer. It will be placed into the |
169 // top left corner of the editorRect and size is calculated from |
154 // top left corner of the editorRect and size is calculated from |
170 // viewer's real size iExpandedSize and editorRect's width. |
155 // viewer's real size iExpandedSize and editorRect's width. |
171 TPoint tlPoint( |
156 TPoint tlPoint( |
172 editorRect.TextRect().iTl.iX, editorRect.TextRect().iTl.iY ); |
157 editorRect.TextRect().iTl.iX, editorRect.TextRect().iTl.iY ); |
173 TSize prefSize( editorRect.TextRect().Width(), iExpandedSize.iHeight ); |
158 TSize prefSize( editorRect.TextRect().Width(), iExpandedSize.iHeight ); |
174 TRect viewerRect( tlPoint, prefSize ); |
159 TRect viewerRect( tlPoint, prefSize ); |
|
160 // Failures are ignored. |
|
161 TRAP_IGNORE( |
|
162 // Try setting font |
|
163 iRichTextViewer->SetFontL( editorRect.Font() ); |
|
164 // Try applying changes |
|
165 iRichTextViewer->ApplyLayoutChangesL(); |
|
166 ); |
175 iRichTextViewer->SetRect( viewerRect ); |
167 iRichTextViewer->SetRect( viewerRect ); |
|
168 |
|
169 TRect bgRect( viewerRect ); |
|
170 // Move focus rect so that it's relative to field's position. |
|
171 bgRect.Move( -Position() ); |
|
172 SetFocusRect( bgRect ); |
176 } |
173 } |
177 |
174 |
178 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
179 // CESMRViewerFromField::MinimumSize() |
176 // CESMRViewerFromField::MinimumSize() |
180 // --------------------------------------------------------------------------- |
177 // --------------------------------------------------------------------------- |
181 // |
178 // |
182 TSize CESMRViewerFromField::MinimumSize() |
179 TSize CESMRViewerFromField::MinimumSize() |
183 { |
180 { |
184 // Minimum size -> Height: TitleRow + Editor size + Margin |
181 // Minimum size -> Height: TitleRow + Editor size + Margin |
185 // Width: Parent's Width |
182 // Width: Parent's Width |
186 // (so the content pane that holds all the fields) |
183 // (so the content pane that holds all the fields) |
187 TRect rect = Rect(); |
184 TRect rect = Rect(); |
188 TAknLayoutRect row1LayoutRect = |
185 TAknLayoutRect row1LayoutRect = |
189 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
186 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
190 TInt titleHeight = row1LayoutRect.Rect().Height(); |
187 TInt titleHeight = row1LayoutRect.Rect().Height(); |
191 // Add title field height |
188 // Add title field height |
192 TInt totalHeight = titleHeight; |
189 TInt totalHeight = titleHeight; |
193 |
190 |
194 TAknLayoutRect row2LayoutRect = |
191 TAknLayoutRect row2LayoutRect = |
195 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
192 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
196 TInt editorRowHeight = row2LayoutRect.Rect().Height(); |
193 TInt editorRowHeight = row2LayoutRect.Rect().Height(); |
197 |
194 |
198 TAknTextComponentLayout editorLayout = |
195 TAknTextComponentLayout editorLayout = |
199 NMRLayoutManager::GetTextComponentLayout( |
196 NMRLayoutManager::GetTextComponentLayout( |
200 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
197 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
201 // Editor height from Layout data |
198 // Editor height from Layout data |
202 TInt editorHeight = editorLayout.H(); |
199 TInt editorHeight = editorLayout.H(); |
203 // Margin is the outer row's height - editor's layout height |
200 // Margin is the outer row's height - editor's layout height |
204 TInt margin = editorRowHeight - editorHeight; |
201 TInt margin = editorRowHeight - editorHeight; |
297 |
294 |
298 iFieldTopic = CMRLabel::NewL(); |
295 iFieldTopic = CMRLabel::NewL(); |
299 iFieldTopic->SetTextL( KNullDesC() ); |
296 iFieldTopic->SetTextL( KNullDesC() ); |
300 |
297 |
301 iRichTextViewer = CESMRRichTextViewer::NewL ( this ); |
298 iRichTextViewer = CESMRRichTextViewer::NewL ( this ); |
|
299 CESMRField::ConstructL( iRichTextViewer ); // ownership transferred |
302 iRichTextViewer->SetEdwinSizeObserver ( this ); |
300 iRichTextViewer->SetEdwinSizeObserver ( this ); |
|
301 iRichTextViewer->SetParent( this ); |
303 } |
302 } |
304 |
303 |
305 // --------------------------------------------------------------------------- |
304 // --------------------------------------------------------------------------- |
306 // CESMRViewerFromField::ExecuteGenericCommandL() |
305 // CESMRViewerFromField::ExecuteGenericCommandL() |
307 // --------------------------------------------------------------------------- |
306 // --------------------------------------------------------------------------- |
308 // |
307 // |
309 void CESMRViewerFromField::ExecuteGenericCommandL( TInt aCommand ) |
308 TBool CESMRViewerFromField::ExecuteGenericCommandL( TInt aCommand ) |
310 { |
309 { |
311 FUNC_LOG; |
310 FUNC_LOG; |
|
311 TBool isUsed( EFalse ); |
312 if (aCommand == EESMRCmdClipboardCopy) |
312 if (aCommand == EESMRCmdClipboardCopy) |
313 { |
313 { |
314 iRichTextViewer->CopyCurrentLinkValueToClipBoardL(); |
314 iRichTextViewer->CopyCurrentLinkToClipBoardL(); |
|
315 isUsed = ETrue; |
315 } |
316 } |
316 if ( aCommand == EAknSoftkeySelect ) |
317 if ( aCommand == EAknSoftkeySelect ) |
317 { |
318 { |
318 iRichTextViewer->LinkSelectedL(); |
319 iRichTextViewer->LinkSelectedL(); |
319 } |
320 isUsed = ETrue; |
320 } |
321 } |
321 |
322 return isUsed; |
322 // --------------------------------------------------------------------------- |
323 } |
323 // CESMRViewerFromField::ExecuteGenericCommandL() |
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CESMRViewerFromField::SetOutlineFocusL |
324 // --------------------------------------------------------------------------- |
327 // --------------------------------------------------------------------------- |
325 // |
328 // |
326 void CESMRViewerFromField::SetOutlineFocusL( TBool aFocus ) |
329 void CESMRViewerFromField::SetOutlineFocusL( TBool aFocus ) |
327 { |
330 { |
328 FUNC_LOG; |
331 FUNC_LOG; |
329 CESMRField::SetOutlineFocusL ( aFocus ); |
332 CESMRField::SetOutlineFocusL ( aFocus ); |
330 if ( iRichTextViewer ) |
333 if ( iRichTextViewer ) |
331 { |
334 { |
332 iRichTextViewer->SetFocus( aFocus ); |
335 iRichTextViewer->SetFocus( aFocus ); |
|
336 } |
|
337 if ( aFocus ) |
|
338 { |
|
339 SetMiddleSoftKeyVisible( ETrue ); |
|
340 } |
|
341 else if( iRichTextViewer ) |
|
342 { |
|
343 //need to tell action menu that focus has changed |
|
344 iRichTextViewer->ResetActionMenuL(); |
|
345 } |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CESMRViewerFromField::HandleLongtapEventL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 void CESMRViewerFromField::HandleLongtapEventL( const TPoint& aPosition ) |
|
353 { |
|
354 FUNC_LOG; |
333 |
355 |
334 if ( aFocus ) |
356 if ( iRichTextViewer->Rect().Contains( aPosition ) ) |
335 { |
357 { |
336 SetMiddleSoftKeyVisible( ETrue ); |
358 iRichTextViewer->LinkSelectedL(); |
337 } |
359 HandleTactileFeedbackL(); |
338 else |
360 } |
339 { |
|
340 //need to tell action menu that focus has changed |
|
341 iRichTextViewer->ResetActionMenuL(); |
|
342 } |
|
343 } |
|
344 } |
361 } |
345 |
362 |
346 // --------------------------------------------------------------------------- |
363 // --------------------------------------------------------------------------- |
347 // CESMRViewerFromField::SetContainerWindowL() |
364 // CESMRViewerFromField::SetContainerWindowL() |
348 // --------------------------------------------------------------------------- |
365 // --------------------------------------------------------------------------- |